i have a problem with $.ajax({}); I have a single file js: test.js with : Js - 1 var id_post = 2; $.ajax({ url: "test.php", type:"GET", data:"post="+id_post, success: function(msg){ $('.load').html(msg); } }); PHP: In test.hp is: // Test.php <a href="" class="delete">Delete</a> HTML: And: Js - 2 $(function delete() { $(".delete").click(function() { var dataString = 'test=2'; var parent = $(this); $.ajax({ type: "POST", url: "delete.php", data: dataString, cache: false, success: function(html){ parent.html(html); } }); return false; }); }); PHP: "Delete" function not working... Where is the problem? Thanks!
When you make an AJAX request to a PHP script the PHP script needs to echo back something for the javascript to receive back.
You have to write the delete code in JS like this It is in this way because the when the first page load jQuery binds all the events to currently present html.