Let's take a look at an official example.
Instance
Use AJAX requests to get JSON data and output the results:
The code is as follows
Copy Code
$ ("button"). Click (function () {$.getjson ("Demo_ajax_json.js", function (
Usually jquery's submit form submission is not intercepted, but the asynchronous submission with jquery Ajax is rejected, and since the problem is caused by an asynchronous commit, it's a good solution because the jquery Ajax method provides the
Briefly describes the load (url,data,function (RESPONSE,STATUS,XHR)) parameter descriptionThe URL stipulates which URL to send the request to.Data is optional. Specify the data to be sent to the server along with the request.function
var info = document.getElementById ("TXT"). Value;
Jquery.ajax ({
Type: ' Get ',
URL: ' http://localhost:8080/jdom/hehe.do?act= page special effects on ',
Data: "&info=" +info,
Cache:false,
DataType: ' JSON ',//Specifying return type
Client:
Using $.getjson () when transferring the first parameter, that is, the URL, if a cross-domain request must have a parameter with a value of "?", such as:
The code is as follows
Copy Code
$.getjson ("Http://202.19
Preson.js File Contents
The code is as follows
Copy Code
[{' Name ': ' Xiangwen '},{' Name ': ' Mengjie '}]XMLHttpRequest
-json-ajax:[support IE7 above]
The code is as follows
Copy Code
When jquery 1.5 is released, it adds a method Jquery.when (). You can handle multiple AJAX requests at a time. See the jquery API documentation for more details.Collection by Ancker
Jquery.post (URL, [data], [callback], [Type]): Asynchronous
The code is as follows
Copy Code
Using System;Using System.Web;Using System.Data.SqlClient;Using System.Data;Using System.Collections.Generic;Using System.Web.Script.Serialization;public class Getdata:ihttphandler {public void
The content of ajaxtest.htm on the front page is as follows: The code is as follows:Copy code This Page interacts with the background in different ways Set up a Handler. ashx page in the background as follows: The code is as follows:Copy
This is the sava. asp file. It receives and processes data sent from ajax. asp.Dim conn, rsDim connstrDim sqlCmd'Create a database connection object and openSet conn = server. createobject ("adodb. connection ")Connstr = "Provider = Microsoft. jet.
The problems analyzed in this article are amazing. It may be unavailable in general projects. Therefore, you must first understand this application scenario. After analysis, I found that jquery's global $. ajax can be used like this!1.
1. What is the Ajax cache principle?After Ajax successfully sends the data, it stores the request URL and returned response results in the cache. When Ajax is called to send the same request, it retrieves data directly from the cache to improve the
Jquery's tool functions encapsulate the processing methods of commonly used strings, numbers, arrays, and objects. Below are some of the commonly used methods:String operation The code is as follows:Copy code Var str = 'www.111cn.net ';Console.
Jquery encapsulates three layers of ajax:Layer 1: $. ajax, Layer 2:. load $. get, $. post, Layer 3: $. getScript, $. getJsonFirst, let's learn how to use. load:Format: load (url [, data] [, callback]) The simplest get method to get text content
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