.ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!! Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
2 posters

    .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!!

    JScript
    JScript
    Forumember


    Male Posts : 741
    Reputation : 175
    Language : PT-BR, EN
    Location : Brazil

    .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!! Empty .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!!

    Post by JScript June 4th 2015, 9:21 pm

    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/ :
    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
    SLGray
    SLGray
    Administrator
    Administrator


    Male Posts : 51515
    Reputation : 3519
    Language : English
    Location : United States

    .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!! Empty Re: .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!!

    Post by SLGray February 23rd 2017, 7:59 am

    This will no longer be supported by JScript: https://help.forumotion.com/t151137-in-memory-of-jscript-joao-carlos.



    .ajax() vs .get() -> get = 1 request and ajax = 2 requests???!!! Slgray10

    When your topic has been solved, ensure you mark the topic solved.
    Never post your email in public.