我有几个div id,每个id都包含不同的客户端。我希望能够点击删除按钮,并使用Ajax和jQuery从数据库中删除特定的div。我在AJAX中取得了成功,但它并未从数据库中删除任何内容。显然,删除后,我想容器重新加载动态。帮帮我!!!使用ajax和jquery删除div id并从数据库中删除
function DeleteClient(){ clientID = $('.clientblock').attr('id') alert(clientID); var yes = confirm("Whoa there chief! Do you really want to DELETE this client?"); if (yes == 1) { dataToLoad = 'clientID=' + clientID + '&deleteclient=yes', $.ajax({ type: 'post', url: '/clients/controller.php', datatype: 'html', data: dataToLoad, success: function(html) { alert('Client' + clientID + ' should have been deleted from the database.'); $('#clientscontainer').html(html); }, error: function() { alert('error'); }});}; }; controller.php info // Variables necessary are: $deleteClient $clientID on the delete click, when being passed through post (via firebug) clientID = 0 deleteClient = yes
编辑:所以很明显,它没有得到正确的客户端ID将其删除的数据库,因为它是通过职位,但我得到一个AJAX的成功呼叫,在那里我有客户端ID变量显示那里,它正在挑选正确的客户端ID。
alert(clientID) is pulling in 0 as well.
任何想法?
你必须在这里放一些关于你的controller.php的信息。 尝试使用Firebug来跟踪发布到控制器的帖子,看看发生了什么 - 参数等。 – ronaldosantana 2010-04-12 22:45:29