About Ajax Cross-domain problem, sorted out today, in fact, there are other ways, personally recommended the following 4 kinds. Please refer to: Ajax cross-domain instanceOne, the traditional Ajax method
1,js Code
$ ("#ajax"). Click (function () {$
When the mobile Web page is too long, you can block the content and load it with Ajax.
The main ideas are as follows: Store the pages that need to be loaded in a new page, main code:
header ("Access-control-allow-origin: *");
Header
Load () method
Load (URL [, data] [, callback]) loads the remote HTML file code and inserts it into the DOM.
Parameter name type description
URL string requests the URL address of an HTML page
Data object sent to the server's Key/value
Callback
jquery is a packaged JavaScript class library that has its own syntax, and I'll talk about implementing Ajax in the 3 method below jquery. Let's start with the example.
The first method of $. Post (Url,data,callback, type);
First create a new HTML
Example: Load from Test.js, the name of the JSON data accessed from the returned JSON data
$.getjson ("Test.js", function (JSON) {Alert ("JSON data:" + json.users[3].name);});
For example, loading JSON data from Test.js, and additional data
Ajax more focused on the front page asynchronous display of the Background database field, the main idea is similar to the previous article, focusing on the DAL layer to get stored in the process of the table collection dataset, in general stored
This is a community arrangement of a holiday small homework, I just put forward my own solution, not necessarily the most appropriate.
The effect is roughly as follows:
Photo sharing:
This piece of
Ajax Entry Detection User name instance and implementation method
Username:
We also need a back-end page to determine if the input nickname exists (in this case, for example, PHP tutorial):
...
if (isset ($_get[' entryname ')
A method of automatic time saving for AJAX dataWindow.onload=function () {
var txtobj = document.getElementById (' txt1 ');var spanobj = document.getElementById (' s1 ');
Automatically saveTxtobj.addbehavior ("#default #userdata");
var
Use XMLHTTP Ajax to automatically save information complete JS code Function Createhttphandler () { var HttpHandler = false; @if (@_jscript_version >= 5) //JScript gives us conditional compilation, we can cope with old IE Versions. The
Load an XML file with XML HTTP
When you send a xmlhttprequest to retrieve data, the user clicks a button.
using the HttpRequest object
Status:
status text:
Response:
get xml
Get the results.
Using the HttpRequest Object
Status: A
Now more popular using jquery Ajax to achieve some no refresh request effect, this section provides a very simple example of code for your reference, I hope to be able to bring some help to the needs of friends, the code is as follows:
Resolves the interceptor's interception of Ajax requests
Interceptor Configuration:
public boolean prehandle (HttpServletRequest request, httpservletresponse response, Object obj) throws Exception {//Get the decision to log whether the
The example in this article describes how Ajax traverses an XML document. Share to everyone for your reference. The specific analysis is as follows:
The XMLHttpRequest object provides two properties that can be used to access the server response.
The main content of this section is to call the page background code method through AJAX to achieve the two-level linkage effect of the drop-down box. The implementation steps are as follows:1. Create the file Recipe24.aspx and implement the
In phpFor an ajax request, the value of the following expression is true. The code is as follows:Copy code $ _ SERVER ["HTTP_X_REQUESTED_WITH"] = "XMLHttpRequest" Is an environment variable of PHP.Ci solution The code is as follows:Copy code
First, you must create a website to create the following files: Web forms (Default. asp tutorial x), JScript File (ajax. js), Web service (SayHelloService. asmx), Class (Hello. cs)(Add: you need to add a Microsoft. Web. Preview. dll file to download
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service