Why is AJAX request terminology causing confusion?

  • Context: MHB 
  • Thread starter Thread starter shivajikobardan
  • Start date Start date
  • Tags Tags
    Request
Click For Summary
SUMMARY

The discussion centers on the confusion surrounding AJAX request terminology, particularly the roles of event handlers and the XMLHttpRequest (XHR) object. Users often misinterpret the concept of events being fired by the XHR, believing that only user actions can trigger events. The conversation clarifies that while user actions like clicks initiate event handlers, the XHR also fires events such as onLoad and onError, which are crucial for handling server responses. Understanding these distinctions is essential for effectively implementing AJAX in web applications.

PREREQUISITES
  • Understanding of AJAX and its components, specifically XMLHttpRequest (XHR)
  • Familiarity with JavaScript event handling and event listeners
  • Knowledge of client-server communication in web development
  • Basic understanding of asynchronous programming concepts
NEXT STEPS
  • Research the lifecycle of an XMLHttpRequest in AJAX
  • Learn about JavaScript event delegation and how to manage event handlers
  • Explore the differences between synchronous and asynchronous requests in AJAX
  • Study error handling in AJAX requests, including onError and onLoad events
USEFUL FOR

Web developers, particularly those working with JavaScript and AJAX, as well as software engineers looking to enhance their understanding of client-server interactions and event-driven programming.

shivajikobardan
Messages
637
Reaction score
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
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.
 
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.
 

Similar threads

Replies
1
Views
3K
  • · Replies 22 ·
Replies
22
Views
2K
Replies
1
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K