Bryant Likes's Blog

It's all about WebData

Recent Posts

Tags

News


  • Windows Live Alerts
    View Bryant Likes's profile on LinkedIn

    Me

    The posts on this weblog are provided "as is" with no warranties and confer no rights. The opinions expressed herin are the personal opinions of the individual authors and do not represent the views of Avanade in any way.

Community

Email Notifications

Archives

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

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.

 

 

Comments

Shanbooz said:

Holly ***, 3 days of trying and trying, and all it was ms fault, i almost committed suicide. crap
# March 9, 2006 9:08 AM

Sasquatch said:

Thank you for posting a solution to this annoying little problem. Much appreciated.
# April 17, 2006 9:04 PM

Sharbel said:

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!
# May 26, 2006 5:34 PM

matt said:

thank you
# July 18, 2006 8:41 AM

mike said:

THANKS A LOT FOR THIS POST!!!!!!!!!!!
# August 10, 2006 11:11 AM

Eyal said:

Thanks man! great post!

# August 15, 2006 2:27 AM

Ryan said:

Honestly I was heading to the gun store to end it all when I found this. My children thank you...

# August 16, 2006 2:50 PM

sanjeev said:

Thanks man i was about to shoot my colleague for crashing my 3 days of hard work :)

# August 24, 2006 5:28 AM

Michael Stuart said:

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.

# August 27, 2006 12:18 PM

Jens Christian Mikkelsen said:

Thanks a million. This bug was driving me crazy, until I found your blog!!!

# August 30, 2006 1:56 AM

Vitoc said:

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.

# September 11, 2006 3:36 PM

Rameshwar said:

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

# September 25, 2006 8:06 AM

MASLIVAK - Marcio Antonio Slivak said:

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!

# October 6, 2006 5:31 AM

Jundenghu said:

Thanks.

# October 15, 2006 8:55 AM

aagarwal8 said:

Thanks a Ton!! i would have gone mad, had this posting not been there.

# October 17, 2006 11:35 PM

Jay K said:

Thanks a lot, I was going nuts, this really solved my issue

# October 24, 2006 10:59 AM

Brandon Young said:

Just what I needed Thanks.

# November 7, 2006 9:59 AM

jafoaz said:

thanks!!! Worked like a charm.

# December 13, 2006 3:51 AM

Sara said:

Thank you!!!.. i havenot tried the soln..but hope this will help...I was only one step away from depression!!

# January 3, 2007 6:03 AM

Fantastic 27 said:

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.

# April 30, 2007 7:23 AM

Alan Mosley said:

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.

# May 5, 2007 6:45 AM

AzamSharp said:

What will happen when you call an Asyncronous method inside a loop? I did a small experiment to find

# May 6, 2007 1:48 PM

Swapneel said:

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!!!

# May 31, 2007 9:02 PM

Ahmad said:

Thanx a lot, it solved my problem really

# June 4, 2007 1:52 AM

Artem said:

Thank you, it was excelent solution

# July 3, 2007 12:01 AM

Najeeb said:

Thanx you, a was really fed up with this error.

# July 3, 2007 3:03 AM

Grey said:

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!

# July 6, 2007 1:20 AM

Venkat said:

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!

# August 1, 2007 12:33 AM

Dhar said:

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

# August 22, 2007 4:08 PM

Jhonatas M. Rodríguez said:

Thank you only replaced the 'i' variable's name for another... Really thank you!!

# August 31, 2007 5:54 AM

Mike T said:

Thank you!

# September 14, 2007 3:43 PM

Hanan Schwartzberg said:

I need to join everyone in thanking you for this post. You just saved me days of searching!!!

# September 18, 2007 5:51 AM

Jody said:

"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.

# October 17, 2007 8:49 AM

Trevor said:

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);

}

# January 11, 2008 8:38 AM

ssj said:

Thank you , it's excelent solution!

# January 16, 2008 4:30 AM

MG said:

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!

# January 22, 2008 11:53 AM

KJ said:

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???

# February 6, 2008 2:55 AM

oshura said:

Lots of thanks!!

Cthulhu f'thang

# April 4, 2008 1:15 AM

Pradeep said:

Thanks for this post.

# April 9, 2008 12:44 AM

Arshad Mahmood said:

Thanks a lot solution dear. Really thanks

# April 19, 2008 1:07 AM

Jayson said:

THANK YOU!!!  Your solution made my day!

# April 22, 2008 6:48 PM

Thomas said:

Unbelieveable... thanks for the solution!!!

# May 6, 2008 11:56 PM

David said:

I can't believe this is still an error in the framework! Thanks!

# July 21, 2008 6:24 AM

Jason said:

THANK YOU!!!  I've been debugging this problem for hours.

# August 22, 2008 12:26 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)