1
我的客戶端腳本中有一個web方法GetNextImage。在ASPX頁面中,我有以下代碼。嘗試使用GET請求調用方法 u0027GetNextImage u0027,這是不允許的
function slideshow() {
$.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "/RollingScreen.aspx/sample",
dataType: "json",
data: "{}",
success: function (data) {
//this changes the image on the web page
$('#imgSlideShow').attr("src","~/Images/1.png");
//fires another sleep/image cycle
setTimeout(slideshow(), 5000);
},
error: function (result) {
alert(result.message);
}
});
}
$(document).ready(function() {
//Kicks the slideshow
slideshow();
});
我收到如下錯誤。
{"Message":"An attempt was made to call the method \u0027GetNextImage\u0027 using a GET request, which is not allowed.","StackTrace":" at System.Web.Script.Services.RestHandler.GetRawParams(WebServiceMethodData methodData, HttpContext context)\r\n at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}
請任何人都可以幫助我。提前致謝。
嘗試鍵入:「POST」,看看你是否得到相同的錯誤 –
@Kirill:非常感謝......它的工作....但現在我在setTimeout(幻燈片() ,5000);在javascript中提到...你能幫我嗎...... – JItendra
它應該是'setTimeout(幻燈片,5000)'。 – Barmar