Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.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_Ajax - Fatal编程技术网

jQuery Ajax无法加载

jQuery Ajax无法加载,jquery,ajax,Jquery,Ajax,我使用jQuery向php页面发出ajax请求。我使用的东西与以下javascript代码类似: $.ajax("#putItHere", { success:"test.php?fish=pope" }); 请注意,这在$putItHere.loadtest.php?fish=pope中运行良好。有人能告诉我为什么这不起作用吗?正确的语法是: $.ajax("test.php?fish=pope", { success: function(result) {

我使用jQuery向php页面发出ajax请求。我使用的东西与以下javascript代码类似:

$.ajax("#putItHere", {
    success:"test.php?fish=pope"
});
请注意,这在$putItHere.loadtest.php?fish=pope中运行良好。有人能告诉我为什么这不起作用吗?

正确的语法是:

$.ajax("test.php?fish=pope", {
    success: function(result) {
        $("#putItHere").html(result);
    }
});

我想这就是你想要的…

你在干什么?success参数应该是一个函数,而不是URL。阅读$.load的文档,它显示了它的缩写$.ajax调用。以及@Barmar正在寻找的链接。实际上,.load的文档没有显示等效的$.ajax代码,尽管它们可能应该显示。$.ajax使用url键/值。它的语法与.load不同。别这么想。是的,我知道我做了什么,我只是认为语法是同样愚蠢的错误。
$.ajax({
    url: "test.php",
    data: { fish: 'pope' },
    success: function(data){
    // do stuff with returned data here
    });