.ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!!
2 posters
Page 1 of 1
.ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!!
Hello friends!
I'm surprised, perhaps by my lack of knowledge / information on the subject about using the .ajax() vs the .get()!
But in the console of my browser the .ajax() makes two requests for reading, while .get() only makes one!!!
Test the codes below to prove it...
.ajax() with the type option = 'get' - as is theoretically get() is a shortcut of ajax() - , according to information from the official website https://api.jquery.com/jquery.get/ :
.get() :
Note that two requests are made using .ajax() and only one for the .get()!!!
The worst is yet to come, execute the code below using .ajax() and the type option: 'post' :
And now we only have a single request in .ajax() !!!
Does anyone want to comment?
JS
I'm surprised, perhaps by my lack of knowledge / information on the subject about using the .ajax() vs the .get()!
But in the console of my browser the .ajax() makes two requests for reading, while .get() only makes one!!!
Test the codes below to prove it...
.ajax() with the type option = 'get' - as is theoretically get() is a shortcut of ajax() - , according to information from the official website https://api.jquery.com/jquery.get/ :
- Code:
console.clear();
var post = 1; // A number of post for testing!
jQuery.ajax({
url: '/post?p=' + post + '&mode=editpost',
cache: false,
type: 'get',
dataType: 'html',
success: function(response) {
console.log('Done!');
}
});
.get() :
- Code:
console.clear();
var post = 1; // A number of post for testing!
jQuery.get('/post?p=' + post + '&mode=editpost', function(data) {
console.log('Done!');
});
Note that two requests are made using .ajax() and only one for the .get()!!!
The worst is yet to come, execute the code below using .ajax() and the type option: 'post' :
- Code:
console.clear();
var post = 1; // A number of post for testing!
jQuery.ajax({
url: '/post?p=' + post + '&mode=editpost',
cache: false,
type: 'post',
dataType: 'html',
success: function(response) {
console.log('Done!');
}
});
And now we only have a single request in .ajax() !!!
Does anyone want to comment?
JS
Re: .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!!
This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Recursive Member Requests via AJAX Causes Bugs
» Ajax reply - all versions
» help set ajax cookie
» Fixed a bug of ajax-profil_edit
» A bug of ajax-profil_edit function
» Ajax reply - all versions
» help set ajax cookie
» Fixed a bug of ajax-profil_edit
» A bug of ajax-profil_edit function
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum