小编kij*_*ana的帖子

在jquery ajax发布成功后调用方法

我正在尝试uploadedImagesRefresh()在POST请求成功时调用方法.代码有时工作,但有时它无法调用,uploadedImagesRefresh()但我必须说后端是好的,Post请求成功完成.

function refreshUploadedImages() {//this
    //function works quite well in other calls
}

$(function(){
    //
    $('.delete-img-btn').live('click', function() {

        //asign the image id from the button attribute 'img-id'
        var id= $(this).attr('img-id');
        //The data to be send via ajax the server will recieve 2 POST variables ie. 'action' and 'id'(which is the img id)
        var data={
            'pk':id,
            //call refreshUploadImages() upon succesful post
            'success':refreshUploadedImages
        };
        //The ajax request.

        $.post("/admin/image-uploader/delete/"+id , data);

    });
});
Run Code Online (Sandbox Code Playgroud)

我在上面的代码中做错了什么?

javascript ajax jquery

3
推荐指数
1
解决办法
1943
查看次数

标签 统计

ajax ×1

javascript ×1

jquery ×1