wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes not understanding the syntax of AJAX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "not understanding the syntax of AJAX" Watch "not understanding the syntax of AJAX" New topic
Author

not understanding the syntax of AJAX

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Hi,

I was trying an AJAX demo given by David O'Meara -- thanks again David -- have lots of doubts.

Here is the partial code (couldn't post whole because of JR problem):



Now, when I execute this application, I get a page with link 'send' and when I click that link, I get alerts in following order:

'check 0'
'check 1' (in the background) and 'check 0.5' both at the same time
If I press okay for 'check 0.5' alert I get one more alert something like this:

error fetching data!

readyState:4
status:404
and all headers information
(this alert is pesent in net.js)


Now my first confusion is, if you see the sendCall() JS function, 'check 0' is okay, then the next line is calling the following code of net.js file:



How that line is calling this code???

The signature of this function in net.js file is very confusing? Can any one make it clear for me?

I have some more doubts also, will ask later.

Thanks a lot.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
What does error 404 mean? Page not found. You are calling a file that does not exist.

Eric
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

How that line is calling this code???



The third parameter is the callback triggered when an error occurs.
You're are passing an empty string, so the default handler (defaultError) will be called. You're getting a 404 error, that's why defaultError is being called.


[My Blog]
All roads lead to JavaRanch
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Thanks Satou.



The above code is inside try block, how can we define a function inside any try block? And what this function is doing?

Thanks.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

You're not trying to change net.js, are you ? I don't think you should touch the existing functions of this library.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Satou kurinosuke:
You're not trying to change net.js, are you ? I don't think you should touch the existing functions of this library.


I am just adding some alerts to understand the flow and functionality. Why?

Is it not like any other JS file? Why you referred it as library?


:roll:
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Order my book!

LOL

That is where the code came from!

Eric
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: not understanding the syntax of AJAX
 
Similar Threads
Array of checkboxes
Inexplicable JavaScript behaviour
AJAX
Problem with Ajax Double Combo
jquery - ajax call to another site and parse result