Tag:ajax

  • Solution to Ajax aborted error request interrupt in IE6

    Time:2021-9-17

    A click event is bound to the a tag to trigger Ajax requests. In IE6, requests are often interrupted, and everything is normal in other browsers. When fiddler2 and httpwatch are used to monitor requests in IE6, there is often “aborted“, which has been tossed for a long time, which is quite strange. Later, the […]

  • Ajax cross domain query is perfectly solved through $. Getjson()

    Time:2021-9-16

    reason:Browser security is restricted to prohibit Ajax from obtaining data across domains.resolvent:Data in JSON format can be obtained across domains through $. Getjson () provided by jQuery. Advantages: strong compatibility. Java background code: Copy codeThe code is as follows: protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String callback =req.getParameter(“callback”);// Custom function name […]

  • Ajax — an example of asynchronously checking the existence of a user name

    Time:2021-9-13

    When registering a user on any website, it will check whether the user already exists. Long ago, the processing method was to submit all data to the server for verification. Obviously, the user experience of this method is very poor; Later, with Ajax and asynchronous interaction, when the user enters the user name and continues […]

  • Analysis of Ajax garbled code and its error solution

    Time:2021-9-12

    One is the occurrence of garbled code, and the other is the occurrence of JavaScript system error: – 1072896658. Prompt inXX.innerHTML=xmlhttp.responseText;This line.In fact, it is all caused by inconsistent coding.The solution is to add the specified character encoding instruction. 1、 What is character encodingAs defined in: http://zh.wikipedia.org/wiki/%E5%AD%97%E7%AC%A6%E7%BC%96%E7%A0%81 。Generally speaking, the “I” you see is a […]

  • Ajax generated stream file download (implementation code)

    Time:2021-9-11

    Copy codeThe code is as follows: //Bind Export button    $(“#btnExport”).clickCheckLogin(function () {         var form = $(“<form>”);        form.attr(‘style’, ‘display:none’);        form.attr(‘target’, ”);        form.attr(‘method’, ‘post’);        form.attr(‘action’, ‘AjaxPost.aspx’);        var input1 = $(‘<input>’);        input1.attr(‘type’, ‘hidden’);        input1.attr(‘name’, ‘type’);        input1.attr(‘value’, ‘Export’);        var input2 = $(‘<input>’);        input2.attr(‘type’, ‘hidden’);        input2.attr(‘name’, ‘fileId’);        input2.attr(‘value’, fileId);        $(‘body’).append(form);        form.append(input1);        form.append(input2);         form.submit();        form.remove();    }); Post the parameter […]

  • AJAX is a relatively clear article

    Time:2021-9-10

    1、Ajax (Asynchronous JavaScript and XML) Ajax definition: the technology that allows the client browser to communicate with the server without refreshing the current page is Ajax technology. 2. The technologies that do not refresh the page and communicate with the server include Ajax, flash, Java applet, iframe, frameset and XMLHttpRequest. Note: the framework is to […]

  • Example of calling webmethod method in aspx.cs page with juery’s Ajax method

    Time:2021-9-9

    First, create a public static method in the ASPX. CS file, and then add the webmethod attribute.For example:[WebMethod] public static string GetUserName() { //…… } If you want to operate a session in this method, you must also set the enablesession property of webmethod to true. Namely:[webmethod (enablesession = true)] / / or [webmethod (true)]public […]

  • The JSON content returned by AJAX is sorted using the sort () method

    Time:2021-9-8

    Key methods:Sort() is used to sort the elements of the array.Return a.num-b.num is in ascending order;return b.num-a.num; It’s in descending orderWriteln adds \ n after the output, which is a line feed in the document and an explanatory space in HTML. Copy codeThe code is as follows: $.post(“json.json”,function(data){ data.sort(function(a,b){return a.num-b.num;}); for(var i=0;i<data.length;i++){ var nums=data[i].num; document.writeln(nums); […]

  • Ajax two solutions to prevent users from submitting repeatedly

    Time:2021-9-6

    Methods that can be loaded on the server side: Copy codeThe code is as follows: private void OnLoading() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(” function pageLoad(){var manager = Sys.WebForms.PageRequestManager.getInstance(); “); sb.Append(” manager.add_beginRequest(OnBeginRequest); manager.add_endRequest(OnEndRequest)} var lcPostbackElementID;”); sb.Append(” function OnBeginRequest(sender, args){ lcPostbackElementID = args.get_ postBackElement().id.toLowerCase(); if (lcPostbackElementID === \”btnadwords\”){$get(\”btnAdWords\”).disabled = true; $ Get (\ “btnadwords \”). […]

  • Discussion on the matching problem of MVC submission parameters using Ajax in asp.net

    Time:2021-9-5

    In the MVC of asp.net, if AJAX is used to pass parameters to the server, if the parameters are a class or an array (or list collection) and more complex objects, the server will always fail to get the value. Of course, there are many solutions on the Internet, but they are all solved by […]

  • Generation example of XMLHttpRequest object in AJAX in different browsers

    Time:2021-9-4

    Copy codeThe code is as follows: <script type=”text/javascript”> function ajax() { var xmlHttp; try { // Firefox, Opera 8.0+, Safari xmlHttp=new XMLHttpRequest(); } catch (e) { // Internet Explorer try { xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”); } catch (e) { Alert (“your browser does not support Ajax!”);return false; } } } </script>

  • Ajax Reading database content to achieve two-level linkage drop-down selection menu example

    Time:2021-9-3

    Copy codeThe code is as follows: < pre class = javascript name = “code” > < / pre > < pre class = javascript name = “code” > ———————————————————————- — < / pre > < pre class = javascript name = “code” > < / pre > < pre class = javascript name = “code” […]