Why is AJAX request terminology causing confusion?

  • MHB
  • Thread starter shivajikobardan
  • Start date
  • Tags
    Request
In summary, the terminology used in AJAX requests, specifically the terms "asynchronous" and "synchronous," has caused confusion for developers. This is due to the fact that these terms are often used interchangeably, despite having different meanings and implications in the context of AJAX. This confusion can lead to errors in coding and difficulties in understanding the functionality of AJAX requests. To avoid confusion, it is important for developers to have a clear understanding of the differences between asynchronous and synchronous requests in AJAX.
  • #1
shivajikobardan
674
54
https://lh5.googleusercontent.com/9QsQWXl9st7BwAufKwea7kxOpXwRzJCEIvN0MWmtaJy9aHgfopZQQ0pYHtcXfoNAJzGbP-x89zFcYwzI7FcZnNlHRI3eezngpJUJq1tPIYpCUImKTqvRlDTjScYf7n0jY9-NoMZLgl9dt-MOLQ
Its explanation-:
https://lh5.googleusercontent.com/CCx_IRo7MJecVwlnMs9nMSIoZ_xfnV1ZGjP8OeXUzrTWmj-njI9SI8B0ULE3RfLyft1LInYv7eWe3hCg-1PxKtQUamiY69mBLQTUewEkYsNtYIIyAxlw5Ik8B6N1mpZcHBy8Yu5N3hk1d_X41A
Confusions(“ie” means my interpretation that i am not sure if is correct or not)-:

1) user clicks invoking an event handler.
i.e when an user event occurs, it makes a javascript call. most likely user event=function call

2) handler's code creates xmlhttprequest object
ie that javascript call creates xmlhttprequest in ajax engine.

3) xhr requests file from server

4) server sends the file.

5)NOW I AM CONFUSED.
the terminologies are confusing me.
like-:
a) xhr fires an event. what does that mean? and why to fire an event? Doesn’t user only fire event? Like clicking,pressing some key etc.

b) you can attach handler function to event. (maybe it is trying to talk about event handler i.e if event->handlerfunction() )..I am not sure.

handler fxn then processes the data and displays it.
 
Technology news on Phys.org
  • #2
If a user clicks a button, the user interface engine fires an onClick event, which invokes whatever event handler has been attached to it. In this case it means an http request is sent out.
When the result of the http request comes back, the http engine (called xhr in this case) fires an http response event, which in the same fashion invokes whatever event handler has been attached to it. In this case the result is somehow presented in the user interface.
 
  • #3
Klaas van Aarsen said:
If a user clicks a button, the user interface engine fires an onClick event, which invokes whatever event handler has been attached to it. In this case it means an http request is sent out.
When the result of the http request comes back, the http engine (called xhr in this case) fires an http response event, which in the same fashion invokes whatever event handler has been attached to it. In this case the result is somehow presented in the user interface.
thanks for reply.
 

FAQ: Why is AJAX request terminology causing confusion?

What is an AJAX request?

An AJAX (Asynchronous JavaScript and XML) request is a technique used in web development to send and receive data from a server without reloading the entire web page. This allows for a more seamless and interactive user experience.

How does an AJAX request work?

When a user performs an action on a web page, such as clicking a button, an AJAX request is sent to the server. The server then processes the request and sends back a response in the form of data, usually in JSON or XML format. The client-side JavaScript then handles the response and updates the web page accordingly.

What are the benefits of using AJAX requests?

One of the main benefits of using AJAX requests is that it allows for faster and more efficient data retrieval and updating without interrupting the user's experience on the web page. It also reduces the amount of data that needs to be transferred, resulting in a more responsive and interactive website.

Are there any limitations to using AJAX requests?

One limitation of AJAX requests is that they are subject to the same-origin policy, meaning that the request can only be made to the same domain as the web page. Additionally, since the requests are asynchronous, it may be difficult to maintain the order of data retrieval and updates.

How can I troubleshoot common AJAX request confusions?

If you are experiencing issues with AJAX requests, some common troubleshooting steps include checking for errors in the browser console, ensuring that the request is being made to the correct URL, and inspecting the server-side code to ensure that it is handling the request correctly. It may also be helpful to review online resources and seek assistance from other developers.

Similar threads

Back
Top