我對我的網頁中的按鈕單擊事件有一個jQuery.ajax調用。這個ajax調用將相當多的標記發送回服務器。經過一些處理後,服務器回覆一個小的URL地址。這有時工作正常,但其他時間沒有。我在ajax調用之前有一個斷點,並且在我的WebMethod中也有一些斷點。看起來有時WebMethod甚至沒有被擊中。jQuery.ajax調用有時不會觸發C#WebMethod
什麼可能導致.ajax調用失敗?我假設在我發送的參數中必須有一些東西。但我的標記是escape
。
任何人有任何想法?
$.ajax({
type: 'POST',
url: 'WebServices.asmx/GetBitmapPathForVML',
contentType: 'application/json; charset=utf-8',
data: '{"sVML" : "' + escape($('#divChart')[0].innerHTML) +
'","width" : 800,"height": 600}',
dataType: 'json',
success: function(result) {
var newWindow = window.open ("", "Chart","");
//blah blah
newWindow.document.write("<BODY>");
newWindow.document.write(
'<img src="file" alt="Chart"></img>'.replace('file',result.d)
);
newWindow.document.write("</BODY>");
//blah blah
}
});
你是否能夠一直打到服務,否則如果你沒有發佈任何(空)的方法? – dexter 2011-01-10 15:06:02
檢查jQuery ajax的「錯誤」和「超時」選項,這應該對你有所幫助。另外,如果您調用webservice的方式存在問題,則應該從客戶端收到腳本錯誤。 – 2011-01-10 15:07:59