Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery ajax调用无法正常工作_Jquery - Fatal编程技术网

Jquery ajax调用无法正常工作

Jquery ajax调用无法正常工作,jquery,Jquery,我使用下面的代码为更新页面执行ajax调用。但它只在第一次工作,如果我尝试第二次它重新加载。如果我再试一次,它会起作用。你知道吗?这里怎么了 $(document).ready(function(){ $("a[href*='delete']").click(function(){ var url = $(this).attr('href'); url = 'http://localhost'+url; $.ajax({

我使用下面的代码为更新页面执行ajax调用。但它只在第一次工作,如果我尝试第二次它重新加载。如果我再试一次,它会起作用。你知道吗?这里怎么了

$(document).ready(function(){
    $("a[href*='delete']").click(function(){
        var url = $(this).attr('href');
        url = 'http://localhost'+url;

        $.ajax({
            type : 'GET',
            url : url,
            success : function(data){
                $('#table_div').html($(data).find('#table_div'));
            }
        });
        return false;
    });
});
试试这个

$("a[href*='delete']").on('click', function(){
    var url = $(this).attr('href');
    url = 'http://localhost'+url;
    $.get(url, function(data) {
        $('#table_div').html($(data).find('#table_div'));
    })
    .success(function(data) { $('#table_div').html($(data).find('#table_div')); })
    .error(function() { alert("error"); })
    .complete(function() { alert("complete"); });
});

问候。

您是否检查了浏览器控制台中的Javascript错误?编辑:您还可以使用来停止单击事件的冒泡。