I think the ajax object in it must have attracted a lot of people. A large number of encapsulated ajax logic classes are of great help to us beginners using ajax.
The following is an example of my use: See here
1.
You can create it like this
var url = 'http://yoursever/your/your';
var pars = 'id=xxx';
var myAjax = new (
url,
{method: 'get', parameters: pars, onComplete: yourfunction}
);
parameters represent the parameters you want to pass, such as id=xxx.
The stages of XMLHttpRequest during HTTP request are divided into: Loading, Loaded, Interactive, Complete.
Objects can call your customized methods at any stage, such as onxxxxxx:yourfunction, such as onComplete mentioned above, which is the most commonly used.
The actual code used in the example
function sends(id)
{
c = $('content');
o = $('old-content');
= "<div id='loading'>Loading...</div>";
= ;
= 'none';
= 'block';
var myAjax = new ('content_'+ id + '.html', {method: 'get', onComplete:updates});
}
function updates(response)
{
new ($('old-content'));
new ($('content'));
$('content').innerHTML = ;
}
The following is an example of my use: See here
1.
You can create it like this
Copy the codeThe code is as follows:
var url = 'http://yoursever/your/your';
var pars = 'id=xxx';
var myAjax = new (
url,
{method: 'get', parameters: pars, onComplete: yourfunction}
);
parameters represent the parameters you want to pass, such as id=xxx.
The stages of XMLHttpRequest during HTTP request are divided into: Loading, Loaded, Interactive, Complete.
Objects can call your customized methods at any stage, such as onxxxxxx:yourfunction, such as onComplete mentioned above, which is the most commonly used.
The actual code used in the example
Copy the codeThe code is as follows:
function sends(id)
{
c = $('content');
o = $('old-content');
= "<div id='loading'>Loading...</div>";
= ;
= 'none';
= 'block';
var myAjax = new ('content_'+ id + '.html', {method: 'get', onComplete:updates});
}
function updates(response)
{
new ($('old-content'));
new ($('content'));
$('content').innerHTML = ;
}