javascript - How to create AJAX semi-synchronous behaviour -
Before coming in an easy way to dynamically load my head, Together, and simultaneously link the HTML canvas sections which are stored on the server, but obviously, initialization on the client (when it seems to be important in the inequal environment).
I was thinking that help me find a way to load simple JavaScript scripts Let's define a Looking at three files stored on the server: AJS B.js C.js If the customer complies with the command I do not know how the code 'load' ('BJ') for the execution of 'paus' of script EDIT Thank you for the redsqaure for Yepnope and requirejs suggestions Unfortunately, I do not like them for many reasons For one, needjs are difficult (I'm sure I will come under criticism for this one) My main disturbance with this is that, if it is very difficult to learn, then I can rest it myself I can learn it in this process, and I can control it more. Second, you need to change your style of writing. Switch to Dojo and use Depending on how much you want to customize it. Either you can go to the synchronous XHR route or use a callback (async and recommended). If you wanted to go to another route, your code would look something like this: edit After looking at your opinion, what you want, something is possible And it will be difficult. Below I have a sample / unchecked implementation of a dependency loader where only one call to a file ("file.js") may be possible to load. This will be more complex for many potential dependencies. Besides, I am assuming that these files are coming from the same domain. load ('foo.js') function Instructions for loading the script
foo.js from and executes it as a javascript code.
a = 10;
Load ('ajs'); B = A +10;
Load ('BJ'); C = b + 10;
load ('C.js'); What is the easiest / most reliable way to implement this? I had an idea that the code server had to scan and return all the scripts one at a time. Minimum request php requests are required for this. However, if the customer has already requested the
C.js , the script must be present in the client side, and it will be vendible, especially if
C.js and All its dependent files are large, another option which I believed was to wrap all these server side scripts in one object, such as
C.js :
{depenencies : ['B.js'], code: 'c.age = b.age + 10;' }
C.js The statement, and after that it has been started,
B.js has been loaded.
dojo.declare ("ClassName", [ParentA, ParentB], {...}); It is one thing to declare classes, but the code snippet is needed in every
(['A', 'B', ...], function () {}); Second, in the end, in the end, I do not know where to look at the files, how easy it is that I want the user to be able to define a 'path' variable server side, and each folder / sub of 'pat' -Folders must be searched in
// Say.js AJS and B.J. .. depend on the load (["AJS", "BJS"], function () {// code goes here});
// Usage: Load ("A JS") // A.js -> BJS - & gt; CGS window.load = (function () {var loaded = {}; return function (str, / * internally used / / callback) {if (! Loaded [str]) {loaded [str] = true ; $ Mill (str, function (data) {var matches = data match (/ load) (['|']]. () ["| '']])); If (matches> Lang & gt; 1) Deep window.load (match [1], function () {window.eval (data); if (!! callback) callback ();});} else {// no deps window.eval (Data);}}}}}}}) ();
Comments
Post a Comment