我收到此錯誤「在UAT環境中處理請求」時出錯。在我的本地,代碼似乎工作正常。jquery Ajax responsetext「處理請求時發生錯誤」
This line Utility.WriteLogEvent(「TestService」,strMessage);直接寫入數據庫。無論哪種方式,如果這條線路發生故障,我應該仍然能夠接收來自服務器的消息,因爲它處理得當。
但由於我沒有收到服務器的任何迴應,這意味着我的webmethod無法訪問。
鑑於下面的代碼工作,有什麼我需要在web.config中設置,使其工作?或者我可以在任何地方開始檢查可以給我一些線索的IIS?
謝謝。
$('#lnkTest').click(function() {
alert('Click event is firing!');
$.ajax({
type: "POST",
url: "/_layouts/ServiceForm.aspx/TestService",
data: "{}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (response) {
if (response.d && response.d.length > 0) {
alert(response.d);
}
},
error: function (xhr, err) {
alert('responseText:' + xhr.responseText);
}
});
});
這裏是我的C#Web方法
[WebMethod]
public static string TestService()
{
string strMessage = string.Empty;
try
{
strMessage = "The service is running.";
Utility.WriteLogEvent("TestService", strMessage);
}
catch (Exception ex)
{
strMessage = "TestService fail.";
}
return strMessage;
}
在您的網址方案中進行相應的更改?它可能會成爲問題。檢查你的例外,它試圖訪問哪個特定的位置,它沒有得到webmethod位置 ?第二個問題可能是在瀏覽器中檢查方法的調用(使用Firebug),您會更好地瞭解它嘗試訪問的確切位置。 –
網址很好。這是一個共享點網址,所以我懷疑它與此有關。 –