jQuery AJAX call to an ASP.NET WebMethod

I have the following jQuery AJAX request: function sendUpdate(urlToSend) { var code = AccessCode; var url = urlToSend; var options = { error: function(msg) { alert(msg.d); }, type: "POST", url: "webmethods.aspx/UpdatePage", data: "{ accessCode: " + code + ", newURL: '" + url + "' }", contentType: "application/json; charset=utf-8", dataType: "json", async: true, success: function(response) { var results = response.d; } }; $.ajax(options); } And the corresponding ASP.NET WebMethod: [WebMethod] public static bool UpdatePage(string accessCode, string newURL) { bool result = true; try { HttpContext.Current.Cache[accessCode + "l"] = newURL; } catch { result = false; } return result; } That all used to work correctly with "async:false", however I have to get rid of it as it freezes the browser until the response is received. Now the AJAX request above returns "undefined". Could anybody tell me why it happens and where the problem is? Thanks.
What's undefined, "response" or "response.d"? You should see what the full response object is to see if it's giving you any error messages from the server.

以上就是jQuery AJAX call to an ASP.NET WebMethod的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准