| Author |
[Ajax] if callback function has parameters?
|
ankur rathi
Ranch Hand
Joined: Oct 11, 2004
Posts: 3829
|
|
Here now, how to pass the value to callback function for 'temp' variable? If I change this line 'request.onreadystatechange = updatePage;', browser throw 'type mismatch error'. TIA.
|
 |
Venkatraman Kandaswamy
Ranch Hand
Joined: Jul 07, 2004
Posts: 120
|
|
|
you can make the variables that you want to pass as global variables.
|
--Venkatraman<br />SCJP 1.4<br /><a href="http://kvrlogs.blogspot.com" target="_blank" rel="nofollow">blog</a>
|
 |
Muhammad Saifuddin
Ranch Hand
Joined: Dec 06, 2005
Posts: 1318
|
|
Originally posted by rathi ji:
if you do this: http.onreadystatechange = updatePage(temp); then you are assigning the returned value of updatePage function You could try this: http.onreadystatechange = updatePage(temp); function updatePage(v) { return something { } hope its help [ November 24, 2006: Message edited by: Saif uddin ]
|
Saifuddin..
[Linkedin] How To Ask Questions On JavaRanch My OpenSource
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56191
|
|
Originally posted by Venkatraman Kandaswamy: you can make the variables that you want to pass as global variables.
What a horrible suggestion!
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56191
|
|
You cannot change what somebody else's code is going to pass to the callback function. You need to write your callback to adhere to the signature that the calling code will use. In this case, the callback function is defined to accept the XMLHttpRequest instance. Normally, you could add your data as properties onto that object to "tag along" for the ride, but because IE6 implements it as an ActiveX object, you can't do this in this case. Rather, use a closure: [ November 24, 2006: Message edited by: Bear Bibeault ]
|
 |
 |
|
|
subject: [Ajax] if callback function has parameters?
|
|
|