• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

not understanding the syntax of AJAX

 
Ranch Hand
Posts: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does error 404 mean? Page not found. You are calling a file that does not exist.

Eric
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 3852
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Order my book!

LOL

That is where the code came from!

Eric
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic