Another form of the linkage box, the right-hand side of the linkage is generated with jquery
This is modeled on the JS method of the article modified
First look at the page code:
Copy Code code as follows:
Area:
Let's first enumerate AJAX implementations in jquery and prototype.
Jquery:
Copy Code code as follows:
Prototype
Copy Code code as follows:
The actual introduction of the SetInterval function after
Copy Code code as follows:
var result = unescape (Xmlhttp.responsetext);
var j = eval ("(+ result +)");
Do not use var j = eval (result);
JSON (JavaScript Object notation) is a simple data format that is lighter than XML. JSON is the
Copy Code code as follows:
datatype
Type: String
The type of data expected to be returned by the server. If not specified, JQuery will automatically intelligently judge against HTTP Packet MIME information, such as XML
MIME types are
The AJAX request for jquery is the default request cache is true, which is turned on, and defaults to False when datatype is script and JSONP. Now I want to read the cache in the browser, because the AJAX request data is very large, request once is
Copy Code code as follows:
$.ajax ({
URL: ' This address should be replaced by your own ',
Data: {S_courseid:courseid, Currtime:new Date (). GetTime ()},//Add a timestamp, otherwise it will not automatically update
DataType: ' JSON ',
X-requested-with is often used to determine whether an AJAX request
But sometimes we have to remove X-requested-with.
The following describes a way JS code
Copy Code code as follows:
$.ajax ({
URL: ' http://www.zhangruifeng.com ',
Copy Code code as follows:
var paras= "Ajaxflag=getmarkerids";
var myajax=new ajax.request (
"Addinfohandler.ashx",
{method: ' Get ', parameters:paras,oncomplete:showgetmarkeridsresponse}
);
Because I have a switch database
The parameter (data) passed by the requested Ajax path is received in the action by a variable of the same name (with the set Get method), and the returned data is an array of jquery objects that are involved in the called action. will be
One, usagejquery's load function is a call that requests another file and loads it into the current DOM, and the full format of the Load method is: Load (URL, [data], [callback]) (note that no parameters are get-mode requests, and parameters are
InstanceLoad JSON data from Test.js and display a name field data from the JSON data:
Copy Code code as follows:
$.getjson ("Test.js", function (JSON) {
Alert ("JSON Data:" + json.users[3].name);
});
Definitions and
Since JavaScript has a variety of frameworks, such as jquery, using Ajax has become quite simple. But sometimes in order to pursue simplicity, it is possible that the project does not need to load jquery such a large JS plug-in. But what about the
The example in this article describes how Ajax+jquery implements cascading display addresses. Share to everyone for your reference. The implementation method is as follows:
initialization hello display Administrator information
Copy Code code as follows:
Synchronous transfer Mode
function Requestbyget (nproducttemp,ncountrytemp)
{
var xmlhttp
if (window. XMLHttpRequest)
{
Isie = false;
XMLHTTP = new XMLHttpRequest ();
}
else if (window. ActiveXObject)
{
HTML code:
Copy Code code as follows:
Here is the form content
JS Code:
If the save succeeds, the background returns {"OK": true}; If the save fails, the background returns {"OK": false, "MSG": "Error Message"}
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