Feed Icon  

Contact

  • Bryant Likes
  • Send mail to the author(s) E-mail
  • twitter
  • View Bryant Likes's profile on LinkedIn
  • del.icio.us
Get Microsoft Silverlight
by clicking "Install Microsoft Silverlight" you accept the
Silverlight license agreement

Hosting By

Hot Topics

Tags

Open Source Projects

Archives

Ads

__pendingCallbacks[...].async is null or not an object

Posted in ASP.Net/Web Services at Tuesday, December 20, 2005 1:57 AM Pacific Standard Time

I ran into this issue today while working on my personal ASP.Net 2.0 project. I was getting the error when my callback function (client side) was running one of my custom javascript methods. I did a little googling and came across this post which didn't tell me about my problem specifically, but there were lots of comments about it:

And... does someone after this change gets som kind of bug , when calling method from server and gets "PendingCallbacks[...].async is empty or it is not an object" error on JavaScript Side?

My App still works, but i can not track this bug. Can anyone help?

It turns out that the issue is related to variable scoping in the ASP.Net client side functions:

Actually, if MS replaced the following script code WebForm_CallbackComplete:

for (i = 0; i < __pendingCallbacks.length; i++) {...}

with:
for (var i = 0; i < __pendingCallbacks.length; i++) {...}

("i" is now locally declared instead of the global scope)

.. that would solve most of our problems, I think.

Sure enough, this solved my problem. In my custom javascript method I had a for loop using a variable named “i“ so I was changing the value in the “i“ of Microsoft's code and causing the exception. So if you hit this issue, make sure you don't use “i“ and/or make sure your variables are properly scoped.

 

 

Thursday, March 09, 2006 1:08:17 AM (Pacific Standard Time, UTC-08:00)
Holly shit, 3 days of trying and trying, and all it was ms fault, i almost committed suicide. crap
Shanbooz
Monday, April 17, 2006 2:04:51 PM (Pacific Daylight Time, UTC-07:00)
Thank you for posting a solution to this annoying little problem. Much appreciated.
Sasquatch
Friday, May 26, 2006 10:34:22 AM (Pacific Daylight Time, UTC-07:00)
MY GOD THANK-YOU! I was using "i" as my variable in a callback function and was getting the same error. LoL I was about ready to scrap the Ajax feature of the list rebuild because I was tired of debugging. THank you so much!
Tuesday, July 18, 2006 1:41:01 AM (Pacific Daylight Time, UTC-07:00)
thank you
matt
Thursday, August 10, 2006 4:11:51 AM (Pacific Daylight Time, UTC-07:00)
THANKS A LOT FOR THIS POST!!!!!!!!!!!
mike
Monday, August 14, 2006 7:27:24 PM (Pacific Daylight Time, UTC-07:00)
Thanks man! great post!
Eyal
Wednesday, August 16, 2006 7:50:43 AM (Pacific Daylight Time, UTC-07:00)
Honestly I was heading to the gun store to end it all when I found this. My children thank you...
Ryan
Wednesday, August 23, 2006 10:28:12 PM (Pacific Daylight Time, UTC-07:00)
Thanks man i was about to shoot my colleague for crashing my 3 days of hard work :)
sanjeev
Sunday, August 27, 2006 5:18:45 AM (Pacific Daylight Time, UTC-07:00)
This is an incredible bug. I'm just glad that several people have this issue posted on their blogs like you do!! There is probably a hotfix for this one...but if there is, it's probably only available to huge corporations that demand Microsoft give it to them. That's how I've always heard these little problems get fixed anyway. It's too bad for the rest of us.
Michael Stuart
Tuesday, August 29, 2006 6:56:02 PM (Pacific Daylight Time, UTC-07:00)
Thanks a million. This bug was driving me crazy, until I found your blog!!!
Monday, September 11, 2006 8:36:10 AM (Pacific Daylight Time, UTC-07:00)
Upon first reading this I thought I had found the solution to my problem. I went and changed all my counter variables from i's to j's, fired it up and doh... same error. Upon clicking on the hyperlinked "turns out" text above, the problem can occur even if the variable scoping issues are addressed, particularly when several callbacks are made in quick succession. I haven't found a clean/simple solution to this issue yet. FWIW I'm using the setTimeout(expression, delay) method for now and it seems to have gotten rid of this blasted error.
Vitoc
Monday, September 25, 2006 1:06:49 AM (Pacific Daylight Time, UTC-07:00)
I have the same error in my application where i used callback event handler where i continously calling
callback event after a period of time to get the new data from database on the basis of passed property id as a argument.

so that how can i change this temporary internet file(webresource.axd)? to run my application by make the for loop like this

for (i = 0; i < __pendingCallbacks.length; i++) {...}
with:
for (var i = 0; i < __pendingCallbacks.length; i++) {...}
Please let me know the solution of this problem

Thanks
Rameshwar
Thursday, October 05, 2006 10:31:53 PM (Pacific Daylight Time, UTC-07:00)
Thank you!
It's so simple, but fix a lot of probleams!

I replaced each 'i' on my page per 'p'. And it stops the probleam!
MASLIVAK - Marcio Antonio Slivak
Sunday, October 15, 2006 1:55:17 AM (Pacific Daylight Time, UTC-07:00)
Thanks.
Jundenghu
Tuesday, October 17, 2006 4:35:23 PM (Pacific Daylight Time, UTC-07:00)
Thanks a Ton!! i would have gone mad, had this posting not been there.
aagarwal8
Tuesday, October 24, 2006 3:59:40 AM (Pacific Daylight Time, UTC-07:00)
Thanks a lot, I was going nuts, this really solved my issue
Jay K
Tuesday, November 07, 2006 1:59:50 AM (Pacific Standard Time, UTC-08:00)
Just what I needed Thanks.
Brandon Young
Tuesday, December 12, 2006 7:51:48 PM (Pacific Standard Time, UTC-08:00)
thanks!!! Worked like a charm.
jafoaz
Tuesday, January 02, 2007 10:03:55 PM (Pacific Standard Time, UTC-08:00)
Thank you!!!.. i havenot tried the soln..but hope this will help...I was only one step away from depression!!

Sara
Monday, April 30, 2007 12:23:54 AM (Pacific Daylight Time, UTC-07:00)
God Damn Microsoft. And they wonder why their stuff is crap. When i look at the javascript code for their callback feature, it looks like it was just slapped together and it worked sometimes, and that was good enough for them! I can't believe this crap came from them.
Fantastic 27
Friday, May 04, 2007 11:45:44 PM (Pacific Daylight Time, UTC-07:00)
Thsnk you, I abandoned a page because of this some time ago, this time i was determend to work it out, i luckily found your page straight away.
Alan Mosley
Thursday, May 31, 2007 2:02:16 PM (Pacific Daylight Time, UTC-07:00)
kudos!!! this not only solved my problem but also i got something new to learn about the variable i which is declared. Thanks a ton!!!
Swapneel
Sunday, June 03, 2007 6:52:29 PM (Pacific Daylight Time, UTC-07:00)
Thanx a lot, it solved my problem really
Monday, July 02, 2007 5:01:34 PM (Pacific Daylight Time, UTC-07:00)
Thank you, it was excelent solution
Artem
Monday, July 02, 2007 8:03:09 PM (Pacific Daylight Time, UTC-07:00)
Thanx you, a was really fed up with this error.
Najeeb
Thursday, July 05, 2007 6:20:32 PM (Pacific Daylight Time, UTC-07:00)
Thanks alot for this find. I overlooked their missing declaration and couldnt explain how i was suddenly 5 although it should have been 0.

Good job!
Grey
Tuesday, July 31, 2007 5:33:18 PM (Pacific Daylight Time, UTC-07:00)
I didn't have any javascript method which uses variable i. Still I am getting this error. So made a small change to my .cs

public void RaiseCallbackEvent(string eventArgument) {
.....
//just added this line and now not getting the javascript error.
System.Threading.Thread.Sleep(500);
}

This may help!
Venkat
Wednesday, August 22, 2007 9:08:31 AM (Pacific Daylight Time, UTC-07:00)
You will see this same crash with recursive callbacks; i.e. if your script makes a call to the server from within a callback handler
Dhar
Thursday, August 30, 2007 10:54:09 PM (Pacific Daylight Time, UTC-07:00)
Thank you only replaced the 'i' variable's name for another... Really thank you!!
Jhonatas M. Rodríguez
Friday, September 14, 2007 8:43:51 AM (Pacific Daylight Time, UTC-07:00)
Thank you!
Mike T
Monday, September 17, 2007 10:51:40 PM (Pacific Daylight Time, UTC-07:00)
I need to join everyone in thanking you for this post. You just saved me days of searching!!!
Hanan Schwartzberg
Wednesday, October 17, 2007 1:49:16 AM (Pacific Daylight Time, UTC-07:00)
"You will see this same crash with recursive callbacks; i.e. if your script makes a call to the server from within a callback handler"

^^^ How do you get around this? The problem is I am calling it from an onchange event handler on one control, then on the call back handler i need to fire the onchange event on the second control.
Jody
Friday, January 11, 2008 12:38:55 AM (Pacific Standard Time, UTC-08:00)
You can get around the error when recursively calling another callback inside a callback handler by delaying the call using window.setTimeout.

example:
BEFORE
function MyCallbackHandler(arg,context) {
WebForm_DoCallback(......);
}
AFTER
function MyCallbackHandler(arg,context) {
window.setTimeout("WebForm_DoCallback(......);",0);
}
Trevor
Tuesday, January 15, 2008 8:30:12 PM (Pacific Standard Time, UTC-08:00)
Thank you , it's excelent solution!
ssj
Tuesday, January 22, 2008 3:53:24 AM (Pacific Standard Time, UTC-08:00)
Woo :)

Thank you VERY much. I am calling a callback from a (devexpress) grid callback handler and was having the exact problem. Hopefully this works!
MG
Tuesday, February 05, 2008 6:55:44 PM (Pacific Standard Time, UTC-08:00)
Hey it didnt work for me.
what may be there I replaced all
variables i with ddItemCounter
but still get the same error.

Any more idea???
KJ
Thursday, April 03, 2008 5:15:05 PM (Pacific Standard Time, UTC-08:00)
Lots of thanks!!

Cthulhu f'thang
Tuesday, April 08, 2008 5:44:48 PM (Pacific Daylight Time, UTC-07:00)
Thanks for this post.
Pradeep
Friday, April 18, 2008 6:07:50 PM (Pacific Daylight Time, UTC-07:00)
Thanks a lot solution dear. Really thanks
Arshad Mahmood
Tuesday, April 22, 2008 11:48:26 AM (Pacific Daylight Time, UTC-07:00)
THANK YOU!!! Your solution made my day!
Jayson
Tuesday, May 06, 2008 4:56:07 PM (Pacific Daylight Time, UTC-07:00)
Unbelieveable... thanks for the solution!!!
Thomas
Sunday, July 20, 2008 11:24:34 PM (Pacific Daylight Time, UTC-07:00)
I can't believe this is still an error in the framework! Thanks!
David
Friday, August 22, 2008 5:26:16 AM (Pacific Daylight Time, UTC-07:00)
THANK YOU!!! I've been debugging this problem for hours.
Jason
Monday, October 13, 2008 9:29:30 PM (Pacific Daylight Time, UTC-07:00)
Thank you , it's excelent solution!
Wednesday, December 10, 2008 7:42:53 AM (Pacific Standard Time, UTC-08:00)
CRAP!!!! This is the solution. Thank you, thank you, thank you! I was going to go insane, but you saved me.
Nate Thomson
Comments are closed.