Error: Parse error on line 1: function search(sour^Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'为什么会出现错误?
代码:
function search(source) {
$.ajax({
url: "index.ajax.php",
type: "POST",
cache: false,
dataType: "json",
data: { action:"search", source:source, form:$("form#main").serialize() },
success: function(data) {
//table
$('#table_data').html(data.table);
$("input[name='count']").val(data.count);
$("#time").html(data.time);
//pagination
from = Number($("input[name='start']").val());
to = (Number(data.count) > (Number($("input[name='limit']").val())+from)) ? Number($("input[name='limit']").val())+from : data.count;
if(data.count == 0) {
$('#page_info').html('<p>No results found.</p>');
$('#next').hide();
} else {
$('#page_info').html('<p>Showing '+(from+1)+' to '+to+' of '+data.count+' records in total.</p>');
$('#next').show();
}
},
error: function(data) {
$('#table_data').html('<tr><td colspan="20">Results error. Please contact admin.</td><tr>');
$("#page_info").html("<p>Load error.</p>");
}
});
}
您能澄清一下您发生此错误的上下文吗?您是否试图将您引用的代码解析为JSON字符串? – Simba
欢迎来到Stack Overflow!我尽可能地猜测你的问题,然后编辑你的问题。但是,添加对代码和描述的解释,以便更多具有该主题知识的人员可以看到它。如果需要识别特定问题,请编辑您遇到的特定错误消息。祝你好运! – manetsus
由于一些奇怪的原因ajax调用不能成功,但我发现问题有一个问题,在我的PHP函数在单独的页面上的一行。 – chris