-
Notifications
You must be signed in to change notification settings - Fork 29
PKUTIL.load
kerrishotts edited this page Nov 13, 2012
·
1 revision
(part of PKUTIL)
Return Type: void
Parameters: theFileName ( string ), aSync ( boolean ), completion ( function )
Loads the resource identified by theFileName and calls completion when finished. If aSync is true (the default), the resource is loaded asynchronously.
The resource can be local or remote -- if remote, it should begin with http://
or https://
. If the resource is local, the filename should be a relative reference.
The completion function's signature should have two parameters -- the first a boolean to indicate the success of the load and the second to pass the data returned or an error code should the load have failed.
For example:
PKUTIL.load ( "./framework/ui-gestures.js", true,
function( status, data )
{
if (status)
{
console.log (data);
}
else
{
console.log ('Error occurred: ' + data );
}
}
);
- Requests are made using
GET
, notPOST
. - For WP7, a special queue is used to ensure that only one XHR request is in progress at any time. If more than one XHR request was in progress, the wrong results could be returned, or 404 errors could be returned for valid resources. Even so, pass only true to the aSync parameter.
- For WP7, local resources must be loaded absolutely to
/app/www/
. As such, the filename is automatically transformed to an absolute reference to that point. If this were not done, resources would not load correctly.
0.1 Introduced
0.2 Docs Valid