我想通過AJAX調用調用服務器方法。但是當我點擊按鈕並在那個時候調用AJAX函數時,它顯示錯誤。ReferenceError:AJAX調用服務器方法時未定義json
這裏是我的代碼
<input type="button" id="btn_findsubmit" value="Edit" class="button" />
$(document).on("click", "#btn_findsubmit", function (e) {
var c = $find("<%=cmbobx_search.ClientID %>");
$.ajax({
type: "POST",
url: "schoolregistration.aspx/GetSchoolName",
data: json.stringify({ schoolname: c.get_textboxcontrol().value }),
contenttype: "application/json; charset=utf-8",
datatype: "json",
success: OnSuccessGetSchoolName,
failure: function() {
alert("error! try again...");
}
});
});
[的WebMethod] [ScriptMethod]
public static string GetSchoolName(string schoolName){
//Here is the code
}
現在,當我點擊那個時候JavaScript的按鈕單擊事件工作,但AJAX方法的按鈕不調用服務器方法GetSchoolName(我知道通過執行調試模式)。
,並拋出一個錯誤:
ReferenceError: json is not defined
'json.stringify'需要是'JSON.stringify' –
你想'JSON.stringify()'大寫字母 – DelightedD0D
我投票結束這個問題作爲題外話,因爲它看起來像一個印刷錯誤,或者是一個本地化的問題,如果沒有答案可能會被放棄。 – halfer