小编JIt*_*dra的帖子

尝试使用 GET 请求调用方法 \u0027GetNextImage\u0027,这是不允许的

我的客户端脚本中有一个 Web 方法 GetNextImage。在 ASPX 页面中我有以下代码。

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();
});
Run Code Online (Sandbox Code Playgroud)

我收到如下错误。

{"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 …
Run Code Online (Sandbox Code Playgroud)

jquery

4
推荐指数
1
解决办法
8065
查看次数

标签 统计

jquery ×1