In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how jquery deletes ajax requests". In daily operation, I believe many people have doubts about how jquery deletes ajax requests. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful for you to answer the doubts about "how to delete ajax requests by jquery". Next, please follow the editor to study!
1.jquery.ajax request aspx
The static method that requests aspx should pay attention to the following problems:
(1) the background method of aspx must be static and add webmethod feature
(2) contentType must be "application/json" in ajax method
(3) the data passed by data must be strict json data, such as "{'axiaxiaqiao", and the parameters must correspond to the parameters of the static method one by one.
(4) the default form of the data returned by the background method of aspx is "{'content returned'}'by 'dashed dataType', so if the dataType is specified as" json ", the returned data must be obtained through data.d.
Define the request method in the background in the webfrom page (the method must be static and the WebMethod feature must be added)
[WebMethod]
Public static string GetString (string str_a,string str_b)
{
Return str_a+str_b
}
Foreground page request
$(function () {)
$.jax ({
Url:'default.aspx/GetString'
Type:'post'
ContentType:'application/json',// must indicate here how the content to be passed to the server is encoded, and it must be json, otherwise the background method cannot get the passed data.
The dataType:'json',// client reads the returned data in the way of json
Data:' {'str_a':'aaa','str_b':'bbbb'}', / / the parameter must be the same as the parameter name in the background. Data must pass data in json format.
Success:function (result) {
Alert (result.d); / / because the default data format returned by the webmethod method is in json format and the data format is such as: "data returned by" {'donglu' returned'} ", so you need to get the returned content through .d.
}
})
})
two。 Request ashx
Pay attention to the problems:
(1) if the contentType in the ajax method must be specified as "application/x-, otherwise the data cannot be obtained by request.form in ashx."
(2) if dataType is json and you want jQuery to parse json data automatically, ashx must return strict json data and must be in the format of double quotation marks (using antisense characters to remove antisense), such as:? context.Response.Write ("{\" d\ ":\" Hello World\ "}"), otherwise jquery will fail to parse json.
(3) if reque.form cannot get the data because contentType is not set or is not a "application/x-" type, you can obtain the request content through context.Request.InputStream.
(4) the data parameters in the request ashx can be in several forms: data: {'afrol a=aa&b=bb'}, data: "a=aa&b=bb", and data: {aVuzazhongzhongbb'}. All three kinds of data can be obtained through request.form ["].
In asp.net webform development, there are several ways to use jQuery ajax to pass values.
1) ordinary play: deal with it through the general handler ashx
2) Advanced play: deal with it through static method + WebMethod in aspx.cs
3) Literary and artistic play: deal with it through WCF.
The first and third methods are beyond the scope of this article, and the second method is emphasized below.
Description
In our impression, asp.net 's Web service ends with .asmx, and our current asp.net can also implement Web service, because System.Web.Handlers.ScriptModule has been added to the default Web.config, which is the HTTP module used to manage the ajax function in asp.net, so that no matter whether the user is requesting .asmx file or .aspx file, the request will be processed through this handler.
At this point, the study on "how to delete ajax requests by jquery" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.