jquery ajax调用失败

时间:2011-05-06 00:03:02

标签: php javascript jquery

$('.deleteBtn').click(function(){
        $('#videofrm').load('edit.php?url='+encodeURI($(this).siblings('a').attr('href'))+'&action=delete');
    })

编辑php代码是:

if($_GET['action']=='delete'){
   echo "<p>daniel</p>";
}

为什么这不起作用?

1 个答案:

答案 0 :(得分:0)

首先尝试通过在第一行之后放置此代码来确定URL是否正确:

alert('edit.php?url='+encodeURI($(this).sublings('a').attr('href'))+'&action=delete');

如果这是正确的,请查明加载功能是否正确执行:

$('#videofrm').load(url, function() {
  alert('url loaded');
});

我猜其中一个会失败..否则它应该正常工作; - )

======================

使用时会发生什么:

$('#videofrm').load('test.html');

和test.html仅包含<p>test</p>