我看到一堆类似的问题,但没有找到我需要的答案。我有这样的功能:从文档准备jquery调用函数
function fnGetContent(keyword) {
var NewKeyword = keyword.tag;
var type = keyword.type;
$.ajax({
type: "POST", //GetEvents(iType As Integer, sSearch As String)
url: "Default.aspx/GetEvents",
data: "{'iType':'"+ type +"','sSearch' : '" + NewKeyword + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
var res = unescape(msg.d);
$("#divResults").html(res);
$('.accordian_body').hide();
$('.accordian_head').click(function() {
$(this).next().animate(
{ 'height': 'toggle' }, 'fast'
);
$('.plus', this).toggleClass('subtract');
$('#<%= tSearch.ClientID %>').val() = 'Search by event, team, artist or venue';
});
}
});
return false;
}
正常工作正在从这里称为:
<a href="javascript:void(0)" onclick="fnGetContent({'type' : '2', 'tag' : 'concert'});">TEST TAG</a>
但我也想呼吁我Document.Ready
这个功能,我想它的权利运行时的页面加载,那么每次我想通过<a href>
更新结果时,我都会打电话给他。这不工作,其他的答案类似的问题是不调用定义出来的准备方面的功能,我知道这是可以调用从多点同样的功能包括的document.ready
$(document).ready(function() {
function fnGetContent("{'type' : '2' , 'tag' : ' ' }");
});
是的,当你调用函数时,当然不是'function'关键字。我没有找到多个错误... – Guffa