Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

not understanding the syntax of AJAX

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does error 404 mean? Page not found. You are calling a file that does not exist.

Eric
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Order my book!

LOL

That is where the code came from!

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic