#1
  1. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,810
    Rep Power
    529

    What is a good word for "not ajax"?


    When the client sends something to the server, it also sets $_GET['asyc'] to 1. I then set a constant called REQUEST_TYPE indicate that the request was via ajax or a traditional request.

    Using the term "ajax" or "asyc" to describe an ajax request is intuitive enough.

    Any recommendations to what I should call it for non-ajax requests? I am currently using "trad" for traditional, but this isn't very descriptive. I know it really doesn't make a difference, but still want something more descriptive.

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,402
    Rep Power
    1688
    Call it Hector?
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2014
    Posts
    8
    Rep Power
    0
    najax
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,939
    Rep Power
    1045
    Hi,

    it makes no sense to distinguish between “Ajax” and “non-Ajax”, because that's not the point.

    The fact that you happen to use Ajax is completely irrelevant for the content. It's just a transportation technique. You might as well do the same thing with WebSocket or Comet or whatever. Or maybe one day you'll want to use the “Ajax content” in a totally different context like a render server. In this case, the whole thing wouldn't be asynchronous at all.

    The criterion for choosing the content is whether the requester wants the full HTML document or just a fragment. That's the difference. So the flag should be named partial or something like that.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,810
    Rep Power
    529
    Originally Posted by SimonJM
    Call it Hector?
    Yes, exactly the word I was looking for!

    Originally Posted by Jacques1
    it makes no sense to distinguish between “Ajax” and “non-Ajax”, because that's not the point.
    I wish the server to return JSON for all ajax requests, and HTML for all non-ajax requests. Why would one not wish to distinguish between them? We had this discussion on this post, and you had a similar position, however, I still think we have a disconnect.

    Thanks
  10. #6
  11. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,939
    Rep Power
    1045
    Originally Posted by NotionCommotion
    I wish the server to return JSON for all ajax requests, and HTML for all non-ajax requests.
    Then make one URL end with .html and the second with .json. Or use a flag or the HTTP headers to distinguish between the expected data types.



    Originally Posted by NotionCommotion
    Why would one not wish to distinguish between them?
    Because whether or not you use the techique called Ajax is totally irrelevant for this scenario. Like I already said, the same thing could be done with a completely different technique. It's not bound to Ajax at all. The webserver doesn't even know that you're using Ajax.

    What if you decide tomorrow that you'd rather want to use WebSocket instead of Ajax? Do you then go through the code and replace every “ajax” flag with a “websocket” flag? And what if you then decide to use Comet instead? Do you again replace all flags? Why? The application logic on the server and even the response haven't changed one bit.

    The flag doesn't even make sense at this very moment. What if somebody uses the JSON resources to scrape your website? This isn't “async” at all.
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,810
    Rep Power
    529
    Originally Posted by Jacques1
    Then make one URL end with .html and the second with .json.
    I would rather not support multiple URL ends.

    Originally Posted by Jacques1
    Or use a flag or the HTTP headers to distinguish between the expected data types.
    I probably will go this way. Still, the server is acting differently based on the request.

    Originally Posted by Jacques1
    The flag doesn't even make sense at this very moment. What if somebody uses the JSON resources to scrape your website? This isn't “async” at all.
    Then I should call the flag "json" and "html".
  14. #8
  15. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,939
    Rep Power
    1045
    Originally Posted by NotionCommotion
    Still, the server is acting differently based on the request.
    Of course, and that's perfectly fine. The thing is that it delivers the content based on what the client wants, not based on which request technique they happened to use.



    Originally Posted by NotionCommotion
    Then I should call the flag "json" and "html".
    That would be an option. A somewhat more elegant solution would be to use the headers, though:

    https://api.jquery.com/jQuery.ajax/#...-ajax-settings
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Sep 2006
    Posts
    1,810
    Rep Power
    529
    Originally Posted by Jacques1
    A somewhat more elegant solution would be to use the headers, though
    Agree. Thanks for the links.

IMN logo majestic logo threadwatch logo seochat tools logo