When invoking a jquery Ajax method, we sometimes need the method to return a value or assign a value to a global variable. But we found out that we didn't get the value we wanted when the program was done, and it's probably because you're using an
Looked at the CI page class did not write about Ajax content, but also saw several other great God wrote the page class extension, it is not really necessary.
Making a small change on the existing basis is still achievable.
Let's get down to
Many of the projects recently developed by the company require Cross-domain AJAX requests, such as several sub domainsHttp://a.****.com/index123.aspx,Http://b.****.com/index2.aspx
To request the user JSON information, and then to process the data,
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
Example:
Rsajax.js:
Copy Code code as follows:
var http_request = false;
function makepostrequest (URL, parameters) {
Http_request = false;
if (window. XMLHttpRequest) {
Http_request = new XMLHttpRequest ();
if
First look at the effect of the picture:
The implementation principle is very simple, uses the jquery.pagination this plug-in, whenever clicks the page number the asynchronous goes to the server to fetch the data of the page, briefly introduces
The page to update
Copy Code code as follows:
Phase I Phase II Hello
Action Page
Copy Code code as follows:
protected void Page_Load (object sender, EventArgs e)
{
if (request.params["data").
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
Load HTML
We typically use HTML-loaded methods to load HTML fragments and insert them in the specified location, assuming the current page is:
load
The contents of the test.html file in the same directory are:
test
We
Directly to say the problem, in a page with jquery (1.6) Ajax request, with the post, passing the display of the array has more than 500. PHP can only accept 50 or so. Initially thought is the Web server Setup problem, put, max_upload_size this kind
jquery Ajax asynchronous request receive return JSON data method Setup is simple, one is the server handler is to return the JSON data, the other is the AJAX send settings datatype set to JSONP format data or JSON format can.
The code example is as
Through jquery's built-in AJAX capabilities, direct access to the background to obtain JSON-formatted data, and then through the Jquer data binding to the previously designed HTML template, directly on the page display.Let's look at the HTML
observation function
The Ajaxstart and Ajaxstop functions can be used as observation functions, and we can use the callback function of the observation function to do the corresponding processing.
The Ajaxstart callback function is triggered when
Ajax synchronization and asynchronous differences, first look at 2 pieces of code:
Code One:
Copy Code code as follows:
Synchronize = function (Url,param) {
function Createxhrobject () {
var http;
var ActiveX = [MSXML2. xmlhttp.
Load syntax
$ (". Selector"). Load ("url", function (ResponseText, statustext, XMLHttpRequest));
Can do to load a page, if there is an error, according to the state given by StatusText, show the corresponding prompts, this is very important to
A common effect, when using AJAX requests, is not to return before the occurrence of a rotating loading small icon or "content loading ..." to inform the user is requesting data. This can be achieved using the Beforesend method.
Download Demo:ajax
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
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.