使用JSON AJAX
語法:
$.ajax({
dataType: "json",
url: url,
data: data,
success: success
});
見簡單的例子爲JSON:
<script type="text/javascript">
$(document).ready(function() {
var msgbox = $("#status");
$("#Button1").click(function() {
$.ajax({
type: "POST",
//Page Name (in which the method should be called) and method name
url: "BeginJson.aspx/CheckDateTime",
// If you want to pass parameter or data to server side function you can try line
// data: "{}",
//else If you don't want to pass any value to server side function leave the data to blank line below
data: "{'args':'Somnath'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
//Got the response from server and render to the client
msgbox.html(msg.d);
}
});
});
});
我已經嘗試了很多東西,最終還是放棄了這個念頭到做這個。問題是,一旦asp.net控件被更改,事件驗證失敗。即我永遠無法一起使用2種技術。我不能重寫所有的服務器代碼,所以我放棄了做部分ajax的想法。謝謝。 – lawphotog 2013-05-31 12:58:44