0
我有兩個Asp項目。在項目A中的對話框關閉時,我正嘗試使用ajax調用來調用項目B中的靜態webmethod。 而不是調用Webmethod它調用PageLoad。Ajax調用Webmethod,跨域
任何想法我做錯了什麼?
的WebMethod
[WebMethod]
public static string UpdateSession()
{
return "Test";
}
$(function() {
$('div#DialogDiv').on('dialogclose', function (event) {
CloseDialog("http://localhost:1330/Application_Default.aspx/UpdateSession");
return false;
});
});
function CloseDialog(URL) {
jQuery.support.cors = true;
$.ajax({
type: "GET",
url: URL,
data: '{}',
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function (response) {
alert("success");
},
failure: function (response) {
alert("Failed to trying to find the method: " + URL);
}
});
return false;
}
謝謝,但結果與我的版本相同,頁面加載仍然被調用。 – Bernie
那麼我猜你的ajax代碼很好!必須是您訪問URL的方式。我不知道如何在這件事上幫助你。抱歉! –