Javascript - Load A Script Synchronously With RequireJS?
Mar 7, 2011
I am using RequireJS in ASP.NET. There is a user control that includes a script file, and registers a startup script in order to initialize itself. Here's the generated code:
So, the problem is that startup script runs before the myctrl.js file has had a chance to run. Currently, the require call uses a callback function, which obviously doesn't run until later, and this is the problem... the script returns and the browser continues to the startup script before MyCtrl has been created.
I have tried simply calling require(['script/dep1', 'script/dep2']); at the top of the file, but that doesn't block either, and the script fails because the dependencies haven't loaded yet. The dependencies are modules, by the way, e.g. they use define().Is there a way to load a script file synchronously with RequireJS? The API documentation says that "Using RequireJS in a server-side JavaScript environment that has synchronous loading should be as easy as redefining require.load()",
I have a Menu page. If a user selects an Menu Item it opens a new IE Window using JavaScript. So user can open different parts of applications in multiple IE Windows. These Windows have the same Session.
My issue is that these pages are accessed synchronously? If one of the child window is waiting for an action to be finished no other request from any other child window is processed. Is it because of using Session variables?
Update: This is only happening to the windows having the same parent. If I have IE child windows from different parent windows then this issue is not there.
I'm trying to use jquery to animate between two images, fading one out then fading the other in.However, I cannot get them to act syncronously, the fadeIn() always gets called before the fadeOut() is complete:
$(function() { var tabContainers = $('#tabwrap > div'); var listItems = $('#tabwrap ul.tabnav li');[code]....
[EDIT] This is running in an ASP website, if that makes any difference whatsoever?
I have an external JavaScript in an asp.net 3.5 project. While writing different functions, sometimes the JavaScript is loaded into FF and sometimes it is not (based on FireBug) and the JavaScript does not run. Even if there is an error in the JS it should still load or be visible to the browser, right?
What is the logic behind when it is loaded and when it doesn't load (or is accessible to the browser?)
Master Page loads JS from a script directory in project:
On the home page of my site I want to display a lot of products which have images which are quite large. Currently the page is taking so long to load that it is actually timing out and the page fails to display!
In MVC, or just ASP.NET in general, how can I load an image asynchronously? Basically what I want to do is display the details of the product and just display a small loading image e.g. ajaxload.info. until the image is loaded.
I assume this is going to require some javascript/jQuery...
I am storing html of error pages of my site in sql table, i want to display them in a window, on the admin side, but not able to load the saved html in iframe, i am using asp.net mvc2.
its needed to save the pages, and display later to admin.
I want to run the LoadArray() function initialy when the page loads. This function is calling a pagemethod given in aspx.vb code file..
Partial Class test3 Inherits System.Web.UI.Page <System.Web.Services.WebMethod()> Public Shared Function Load_Array() As String() Dim Model_Name_old As String()() Dim mod_code As String() Dim mod_name As String() Dim cod_upper As Integer //calling webservice that retunrs a jagged array Dim ins As New localhost_insert_model.dbModel Model_Name_old = ins.get_Model_Name("A") mod_code = Model_Name_old(0) mod_name = Model_Name_old(1) Return mod_name End Function End Class
So how can i load the javascrip LoadArray() function onPageLoad in this scenario?
i have a requirement to show javascript Ok/Cancel option on page load. So, when the user is redirected from the previous page to this page, based on some logic in the query string, we have to display javascript OK/Cancel (page is not yet rendered here). Once the user clicks, we have to load different type of data (server side execution) based on OK/Cancel. what is the best way of accomplishing this task?
I have an ASP.NET page and have a couple of linkbuttons and Iframes. The pages in side of these IFrame take long time to load, I want the user to navigate to another page by clicking one of the linkbuttons. Now, it looks like it is waiting for the the iframes to finish loading when i click on a link button, the page is still trying to load (instead of navigating to different page).
Is there any way I can stop the iframes to load and go to another page?
<script type="text/javascript"> function initialize(lon,lat) { var myLatlng = new google.maps.LatLng(lon,lan); var myOptions = { zoom: 14, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById("map"), myOptions); var marker = new google.maps.Marker({ position: myLatlng, map: map }); } </script>
In my code behind in VB.NET I then want to load such as:
I have a piece of inline java script which is within an AJAX updatepanel. The code works perfectly on 1st load but not when the updatepanel is updated.
i have aspx pages with vb.net in the back. I need to use javascript to open a new window on page load. I am also sending a querystring (www.mysite.com/default.aspx?dest=register.aspx) from the previous page. I need the javascript to parse the querystring and open the new window only if the URL has a querystring.
I have created javascript function as mentioned below to hide/show some control. I am calling this script on dropdown on 'onchange' method. In dropdown first item is "-- Select --". I want to execute it on Page Load function, so by default it will be hidden. I tried to call like this on Page load, but it is not working.
I have a large scale application which uses javascript for many reasons. these javascript files included in some JS files and JS files imported to Asp.net Masterpage files.
this JS files contents (javascript functions) will add to page when page display to user, so a Bunch of waste Javascript functions will include in Asp.net pages.
I'm lookingfor a way which these JS files downloads to users computer (any where, e.g: temporary internet files or some where else) and the Asp.net page use that functions which downloaded with page.
I also want to download 1 time ( per user login or per Open Session ) to users computer.
So How to download JS file to Users PC and Use them in Asp.net Pages
On my Page_Load command for a page, I have a couple of tests that are performed before the screen is displayed with an alert box displaying if the user cannot access the screen. If Not Page.IsPostBack Then
I need to insert some JavaScript code inside a UserControl that I load from an Ajax call via jQuery Ui Tabs. Let me explain... This is my View (with jQuery loaded)
<script type="text/javascript"> $(document).ready(function () { $("#tabs").tabs({ cache: false, }); getContentTab (1); }); function getContentTab(index) { var url='<%= Url.Content("~/Home/getUserControl") %>/' + index; var targetDiv = "#tabs-" + index; $.get(url,null, function(result) { $(targetDiv).html(result); }); } </script> <div id="tabs"> <ul> <li><a href="#tabs-1" onclick="getContentTab(1);">Nunc tincidunt</a></li> <li><a href="#tabs-2" onclick="getContentTab(2);">Proin dolor</a></li> <li><a href="#tabs-3" onclick="getContentTab(3);">Aenean lacinia</a></li> </ul> <div id="tabs-1"> </div> <div id="tabs-2"> </div> <div id="tabs-3"> </div> </div> With these lines of code I call the Ajax function to load the content into a DIV. This is the Action from the controller: public ActionResult getUserControl(int num) { return PartialView("TestUC", num); } And this is the UserControl... <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> Number... <span id="testSpan"><%=Model.ToString() %></span>!! <input type="button" value="Click me!!" onclick="message();" /> <script type="text/javascript"> function message(item) { alert($("#testSpan").html()); } </script>
The problem is that the message() function returns always 1 (instead of returning the correct number). My question is... How should I add the script to my UserControl in order to have my code running correctly?
When we include Javascript files in our aspx files. either we write all the Javascript code in the Head section of aspx or we link to an external Javascript file.
So when the clinet makes a call to that page. Does that mean that all the Javascript will be loaded on the client side?
If that is the case then does not that mean that it will slow down the loading of page as all the Javascript has to be loaded on the client machine?
I have a .net web application in a load balanced environment over 3 servers. The load balancing is done with a load balancer. My site is [URL]with serveral javascript files such as [URL]
Is it possible to set it up that when request goes to server1 for [URL] then all javascript, css requests also go to server1, server2 or server3? Is there any web.config configuration that can be put in place to handle this?
due to this code I am getting a pageload error? is that something wrong with this?this is the Error I am getting in IE.Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.5; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; AskTbF-ET/5.8.0.12304) Timestamp: Fri, 8 Oct 2010 19:30:36 UTC
I have a tab control on my page and on click of tab user control is loaded dynamically.I need to load the javascript file of that user control dynamically. I don't want to add the reference of my js file on parent page.so in my .ascx page load event i added: