2012年8月1日 下午 09:20
We are doing some scripting, where the user clicks a button which examines all the items in a list and then adds some new list entries. We see really wierd behavior with the client object model sometimes. right now, clicking the button calls a method that submits an async request to read all the list entries. The OnSuccess method then examines those entries and calls another method to insert new items.
What we are seeing is that if you click the button once, we get a debug alert showing code entered the code prior to reading all entries, but we never get an alert inside the "onSuccess" method. If we then click the button again, we get the first debug alert, and then the second alert too (from inside the onSuccess method). WHY? Why does the second click seem to return a result whereas the first click doesn't? I brought up fiddler, and it looks like a request is sent to the server and received by the client on both clicks - but only the second one seems to kick off the onSuccess method.
2012年8月3日 上午 10:11版主
Thanks for sharing the post.
I’m trying involve someone familiar with this topic to further look at this issue.
TechNet Community Support
2012年8月3日 下午 02:02
The developer on my team working on this got it figured out - the problem we were experiencing this time was caused by a failing call to web.get_currentUser() - we didn't realize that was an async call also - and the code was failing the first time it ran - I guess the second time we called the method it was batched in with the other async calls we were making.
- 已標示為解答 Qiao WeiMicrosoft Contingent Staff, Moderator 2012年8月12日 上午 11:20
2012年8月3日 下午 09:15
Greetings! Thanks for the post.
I see that you have figured out the real reason behind the OnSuccess method being called only on second button click.
Let me know if you need any information regarding the same.
Please remember to click 'Mark as Answer' on the post that helps you or click 'Unmark as Answer' if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Microsoft Online Community Support