This is a migrated thread and some comments may be shown as answers.

ScriptLoader.loadScripts cannot be called while the ScriptLoader is already loading scripts.

10 Answers 451 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
miksh
Top achievements
Rank 1
Iron
miksh asked on 15 Jul 2008, 08:28 PM
What might cause the error: "Sys.InvalidOperationException: ScriptLoader.loadScripts cannot be called while the ScriptLoader is already loading scripts."?
It happens when a user makes a few clicks on different controls pretty fast. The page contains javascript code surrounded by RadScriptBlock.

10 Answers, 1 is accepted

Sort by
0
Neil Sloan
Top achievements
Rank 1
answered on 16 Jul 2008, 07:57 PM
Are you disabling the page while doing a partial postback?

I do this on all of my pages because I do not want the user to click on anything or do anything while an ajax request is processing.

To disable the page, set the ClientEvents-OnRequestStart on the RadAjaxManager to call a javascript routine.

The javascript function will overlay a div ontop of everything else in the page by setting the zIndex to something rediculously high ( I also set the cursor to wait ) and setting the display to block ( so it appears ).  You have to make sure the div that you display has a background color.

In my specific case, the div that I show is inside of the LoadingPanel, so this way it is automatically hidden when the loading panel goes away.

0
miksh
Top achievements
Rank 1
Iron
answered on 16 Jul 2008, 08:12 PM
This is a nice workaround but it should work by default. Any Telerik's sample works fine without disabling the page.
0
Kiran
Top achievements
Rank 1
answered on 14 Nov 2008, 10:09 AM
I am also facing the same problem with same scenario. Is there any final solution?? or we need to use this workaround??

Thanks
0
miksh
Top achievements
Rank 1
Iron
answered on 14 Nov 2008, 02:08 PM
Here is the Telerik's suggestion I had:

One possible solution for this is setting RequestQueueSize property of RadAjaxPanel/RadAjaxManager. Its default value is 0. You can find more information about this property on the following links:

 RequestQueueSize Property
Ajax requests queueing

Other option is to cancel ajax request if your script is already executing one as shown here:

 

        <script type="text/javascript">  
            Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initRequest);  
            function initRequest(sender, args)  
            {  
                if(Sys.WebForms.PageRequestManager.getInstance().get_isInAsyncPostBack())  
                    args.set_cancel(true);  
            }  
        </script> 

 


I used the second one and it worked fine.
0
Sandeep Pulkundwar
Top achievements
Rank 1
answered on 09 Mar 2009, 10:02 AM
Hi,
can you give a sample code for disabling the page on partial postback?
0
Sebastian
Telerik team
answered on 09 Mar 2009, 11:28 AM
Hello Sandeep,

I think that you can use the approach presented here with modal RadAjaxLoadingPanel to disable the entire page on ajax request.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jgig
Top achievements
Rank 1
answered on 20 Apr 2009, 03:31 PM
I am using ASP.NET AJAX version 2009.1.311.35

Can someone give some more details as to why this error occurs and how to stop it? I have noticed on the demos they usually don't disable the controls and it appears to Queue properly without causing an error. I know disabling the page or control is probably the easiest thing to do but I would like the Queue to work properly and I have set the RequestQueueSize to 3. (I only see the error in IE because it is so slow)

I have noticed that if I put controls inside a RadAjaxPanel I don't get this error. But if I use the RadAjaxManager or RadAjaxManagerProxy instead of the RadAjaxPanel that same piece of code will get this error if you click too fast. In this case I was using a RadTabStrip to show update RadTabStrip and RadMultiPage. The Queue seemed to work here better when it was all place in the RadAjaxPanel. 

What is the difference? Any good articles about these subtle differences? Does the Queue only work when it is the same control doing the AJAX calls?


0
Sebastian
Telerik team
answered on 23 Apr 2009, 10:17 AM
Hello jgig,

It is indeed odd that you encounter the error with RadAjaxManager/RadAjaxManagerProxy only and it is not present when using RadAjaxPanel. Unfortunately I cannot say for certain what might be the exact reason for the issue in your particular configuration.

Therefore, in order to progress in our investigation I request that you send a working copy of your project, exhibiting the erratic behavior with RadAjaxManager and working properly with RadAjaxPanel, attached to a regular support ticket. I will test/debug it locally and will get back to you with my findings.

Also verify that you are using the latest release 2009.1.402 of RadControls for ASP.NET AJAX.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
jgig
Top achievements
Rank 1
answered on 23 Apr 2009, 12:48 PM
I can look into making a project at a different time to figure out why the Panel worked better in this case than the Proxy.

I am more curious as to why this error happens though. If you guys have created a Queue then why does this error occur? What are the limitations or causes as to why it still happens? If it happens does that mean I have something set up wrong?
0
Sebastian
Telerik team
answered on 23 Apr 2009, 01:28 PM
Hi jgig,

Generally, the reason for this error are that the ScriptLoader fails to load additional client scripts because at the same time it already processes other scripts. There is a discussion on this subject in the following ASP.NET forum:

http://forums.asp.net/t/1329989.aspx

In your case it seems that the ajax request queuing through RadAjaxManager conflicts with the page events flow due to some unknown reason. However, in order to provide up-to-the-point explanation, we will need a sample working version of your project to investigate the matter further.
 
Best regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
miksh
Top achievements
Rank 1
Iron
Answers by
Neil Sloan
Top achievements
Rank 1
miksh
Top achievements
Rank 1
Iron
Kiran
Top achievements
Rank 1
Sandeep Pulkundwar
Top achievements
Rank 1
Sebastian
Telerik team
jgig
Top achievements
Rank 1
Share this question
or