【发布时间】:2011-08-24 14:06:28
【问题描述】:
这里是调用ajax函数的jquery:
function sendAjax(type, succ){ //where succ is the success callback
if (type=="")
{
$("#txtResp").empty();
return;
}
if(succ === undefined) { succ = null; }
switch(type)
{
case 'run':
$.ajax({type:"GET",
url: "start_mess.php",
data: "q="+type,
success: succ
});
break;
}
}
这里是index.html页面内容:
function initialLoad()
{
sendAjax('run')
$("#txtResp").html(responseText);
}
initialLoad();
这是 PHP 页面:
echo $_GET['q'];
$q = $_GET['q'];
知道为什么这不起作用吗?谢谢!
泰勒
【问题讨论】:
-
好吧,一方面,
sendAjax('run')后面需要一个分号。我也看不到responseText的定义位置。 -
你知道 JS::onReady 技术吗? api.jquery.com/ready
标签: ajax jquery jquery-selectors