Tag:Ajax request

  • Various solutions for multiple Ajax requests (synchronization, queue, cancel request)


    • multiple Ajax requests are sent simultaneously without dependency.• multiple Ajax requests are interdependent and must be in order.• multiple requests are sent at the same time, and only the last request is required.Case 1Application scenario: there are many scenarios. When a page is opened, multiple regions simultaneously request the background to get their own […]

  • How to circularly output JSON format data returned by Ajax request into table form


    First, AJAX requests data (using jQuery’s Ajax) Copy codeThe code is as follows: <script> $(function(){ $(‘#test’).click(function(){ $.ajax({ url:’__APP__/Article/jsonTest’, type:’post’, success:function(data){ var item; $.each(data,function(i,result){ Item = “< tr > < td >” + result [‘num ‘] + “< / td >” + result [‘title’] + “< / td > < td >” + result [‘credate ‘] […]

  • Sample code for cross domain Ajax requests using $. Getjson


    In jQuery, getjson is often used to call and obtain the remote JSON string and convert it into a JSON object. If successful, the callback function will be executed. The prototype is as follows: JQuery. Getjson (URL, [data], [callback]) loads JSON data across domains. URL: address to send the requestData: (optional) key / value parameter […]

  • Determine whether the request header contains an attribute to determine whether it is an Ajax request


    Copy codeThe code is as follows: <html> <head> <script language=”javascript”> function cl() { var xmlhttp; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp=new ActiveXObject(“Microsoft.XMLHTTP”); } xmlhttp.open(“POST”,”ajax2.html”,true); xmlhttp.setRequestHeader (“Content-Type”,”application/x- www-form-urlencoded”); //By default, jQuery YUI will send a_ X_ REQUESTED_ The HTTP request header message of with, therefore, you can judge whether it is an Ajax […]

  • The data returned by the Ajax request can not be seen, the callback function is not executed, and no error is reported


    The project uses SSH, and uses $. Post of jQuery to access the action of Struts2. There is no error anywhere, but there is no result. Now $. Post needs to return the collection < privilege >, the privilege class is associated with the user class, that is, the set set set in privilege saves […]

  • The solution of IE sending Ajax request to return the last result


    Causes of the problem: 1. Only one Ajax request will be created under ie, and the response result will be put in the browser cache, which will be read from the cache the next time the Ajax request is called In get mode, because the sending parameters and address are consistent, ie will get the […]

  • HTML + JS + PHP an original Ajax request example


    Today, I’d like to show you the original Ajax request process. Although the Ajax of jQuery is much easier than the original writing method, we should still understand the original writing method. Next, I’ll divide it into three small files: HTML, JS and PHP to show. The database will write by itself. First, HTML Copy […]

  • Herf = # results in no data being sent to the background when Ajax requests


    Today, I’m doing the right-click menu. When I click rename for Ajax request, I don’t send data to the background, but jump to the home page directly. I couldn’t understand it. Later, I found a problem on the front page: Copy codeThe code is as follows: <span style=”font- size:24px; “>< Li > < a (?) […]

  • The difference between Ajax request post and get and the choice of get post


    The simplest difference: 1. When using get request, the parameters will be displayed in the URL, but not in the post mode 2. Using get request to send small amount of data, post request to send large amount of data 3. Get requests need to pay attention to caching, post requests need not worry about […]

  • An example discussion on the return sequence of multiple Ajax requests


    Sometimes in a business event processing process, you may encounter an action triggered by clicking a button or other events You need to execute more than two Ajax requests, but you may have to consider the sequence of Ajax requests. Sometimes, problems in the sequence of Ajax requests will lead to various problems For example, […]

  • Open a new window after successful Ajax request window.open () solution to interception


    Question: The previous development project encountered a problem, AJAX asynchronous request after the success of the need to open a new window to open the URL, using the window.open () method, but unfortunately it was intercepted by the browser. How to solve this problem?analysis: The reason why the browser intercepts a new window is that […]

  • Ajax request to add custom header parameter code


    I don’t want to talk much nonsense. Let’s look at the code directly~ $.ajax({ type: “post”, url:””, contentType: “application/json;charset=utf-8”, data :JSON.stringify({“bodyName”:”sdfsdf”,”date”:”2017-11-28 07:34:01″,”price”: 10.5,”tbId”: 1}), dataType: “json”, beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader(“token”, “eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxOD…..”); }, success: function (data) { alert(data); },error:function(error){ console.log(error); } }); beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader(“token”, “eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxOD…..”); }, Among them, token is the header […]