2013-08-30 76 views
-1

我正在使用jQuery向php页面发出ajax请求。我使用类似的东西下面的javascript代码:jQuery Ajax无法加载

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

请不,这工作正常$( “#putItHere”)负载( “test.php的鱼=教皇?”)。任何人都可以给我一个线索,为什么这不起作用?

+1

你在做什么?成功参数应该是一个函数,而不是一个URL。 –

+1

阅读'$ .load()'的文档,它显示了'.ajax()'调用的简称。 – Barmar

+0

http://api.jquery.com/load和http://api.jquery.com/jquery.ajax是@Barmar正在寻找的链接。 (实际上,'.load' *的文档不显示等效的'$ .ajax'代码,尽管他们可能应该这样做。) – Blazemonger

回答

2

正确的语法是:

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

是的,我可以看到我做了什么,我只是假设语法是一样的愚蠢的错误。 – stmfunk

0
$.ajax({ 
    url: "test.php", 
    data: { fish: 'pope' }, 
    success: function(data){ 
    // do stuff with returned data here 
    }); 

我想这是你想要的...