The function "showResponse()", which is passed to Ajax.Request, calls another function "originalRequest()". No mention is made of this "originalRequest()" function in the tutorial, and I have no idea what it means. I have emailed the author twice and he said this:
The function you pass in will be called by the object with two arguments, the first one will be the XMLHttpRequest To be clear, it is the XmlHttpRequest object that carried out the request/response. There's no reference to myAjax in the callback.
Not sure what this means. I have some Ajax code that is currently not working, and I feel this is the reason. I have tried creating XHR object and passing it in, but that did not work. Please help!!! [ July 18, 2007: Message edited by: Bear Bibeault ]
Originally posted by kwame Iwegbue: The function "showResponse()", which is passed to Ajax.Request, calls another function "originalRequest()"
No, it doesn't. Where do you see a function call? The name originalRequest is the parameter that is passed to the showResponses function. It is a reference to the XMLHttpRequest instance used to make the Ajax call.
Not sure what this means.
Do you understand how functions are called and passed parameters?
I have tried creating XHR object and passing it in,
No, it is passed for you.
I have some Ajax code that is currently not working
If you follow the pattern of the tutorial, it should work.
And by the way, when talking about the Prototype library, be sure to capitalize the "P". Otherwise, it could be confused with a constructor's prototype property (with a small "p").
Thanks Bear. I understand now. Also I understood already how functions are passed parameters. My issue was that, it just wasn't explained well in the tutorial. Now you've explained it.
I'm still unable to make my code work though.
(p.s i had to re-write onclick and eval because this system won't allow them in the code) [ July 18, 2007: Message edited by: kwame Iwegbue ]
Thanks Greg. The code comes from the Stripes Ajax page.
By it doesn't work, I mean there's something in this script block thats either not proper syntax or just not the way its supposed to be. It doesn't matter what test code I put in the 'update' function, its simply not being called:
I've even tried calling onFailure:
However, if I replace 'handler' in onSuccess: handler, with alert('works'), it produces an alert box!. Whats that about? [ July 18, 2007: Message edited by: kwame Iwegbue ]
I see no function named "handler" defined in your code.
Joined: Sep 02, 2000
I'm finally getting somewhere. Someone on the Stripes forum recommended I use Firebug, a Firefox pluggin. It did great. Turns out the problem is a missing closing curly brace, and innerHtml should be innerHTML. The code gets to the server now, but I'm still not getting a result. Instead the Result span reads: [object Object]