jQuery Ajax成功函数参数

nul*_*ion 12 javascript ajax jquery

  $.ajax({  
            type: "POST",  
            url: "contacts.php",  
            data: dataString,  
            cache: false,  
            success: function(data, status, settings)  
            {  
               alert(The request URL and DATA);
            }  
            ,
            error: function(ajaxrequest, ajaxOptions, thrownError)  
            {  

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

如何提醒Success函数中的请求URL和DATA参数?

谢谢

Ale*_* K. 23

你可以简单地;

success: function(data, textStatus, jqXHR)
{
   alert(this.data + "," + this.url); 
}
Run Code Online (Sandbox Code Playgroud)


sno*_*orm 5

改编自 Alex K. 的回答,但使用 console.log 代替:

success: function(data, textStatus, jqXHR)
{
   console.log(this.data + "," + this.url); 
}
Run Code Online (Sandbox Code Playgroud)

这会将数据输出到调试控制台而不是模式对话框。