mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-30 10:54:44 +00:00
Add the XHR object to the data passed to loadpage and loadpagefailed callbacks. This was a low-hanging-fruit enhancement request for issue #2503 - User can't specify own error handling logic.
This commit is contained in:
parent
3f488e1cd6
commit
1405a9453f
2 changed files with 35 additions and 3 deletions
|
|
@ -205,6 +205,16 @@ $( document ).bind( "pagebeforeload", function( event, data ){
|
|||
<ul>
|
||||
<li>This object contains the options that were passed into $.mobile.loadPage().</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>xhr</code> (object)
|
||||
<ul>
|
||||
<li>The jQuery XMLHttpRequest object used when attempting to load the page. This is what gets passed as the 3rd argument to the framework's $.ajax() success callback.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>textStatus</code> (null or string)
|
||||
<ul>
|
||||
<li>According to the jQuery Core <a href="http://api.jquery.com/jQuery.ajax/">documentation</a>, this will be a string describing the status. This is what gets passed as the 2nd argument to the framework's $.ajax() error callback.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
|
@ -269,6 +279,21 @@ $( document ).bind( "pageloadfailed", function( event, data ){
|
|||
<ul>
|
||||
<li>This object contains the options that were passed into $.mobile.loadPage().</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>xhr</code> (object)
|
||||
<ul>
|
||||
<li>The jQuery XMLHttpRequest object used when attempting to load the page. This is what gets passed as the first argument to the framework's $.ajax() error callback.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>textStatus</code> (null or string)
|
||||
<ul>
|
||||
<li>According to the jQuery Core <a href="http://api.jquery.com/jQuery.ajax/">documentation</a>, possible values for this property, aside from null, are "timeout", "error", "abort", and "parsererror". This is what gets passed as the 2nd argument to the framework's $.ajax() error callback.</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>errorThrown</code> (null, string, object)
|
||||
<ul>
|
||||
<li>According to the jQuery Core <a href="http://api.jquery.com/jQuery.ajax/">documentation</a>, this property may be an exception object if one occured, or if an HTTP error occured this will be set to the textual portion of the HTTP status. This is what gets passed as the 3rd argument to the framework's $.ajax() error callback.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
|
|
|
|||
|
|
@ -811,7 +811,7 @@
|
|||
type: settings.type,
|
||||
data: settings.data,
|
||||
dataType: "html",
|
||||
success: function( html ) {
|
||||
success: function( html, textStatus, xhr ) {
|
||||
//pre-parse html to check for a data-url,
|
||||
//use it as the new fileUrl, base path, etc
|
||||
var all = $( "<div></div>" ),
|
||||
|
|
@ -897,7 +897,9 @@
|
|||
hideMsg();
|
||||
}
|
||||
|
||||
// Add the page reference to our triggerData.
|
||||
// Add the page reference and xhr to our triggerData.
|
||||
triggerData.xhr = xhr;
|
||||
triggerData.textStatus = textStatus;
|
||||
triggerData.page = page;
|
||||
|
||||
// Let listeners know the page loaded successfully.
|
||||
|
|
@ -905,12 +907,17 @@
|
|||
|
||||
deferred.resolve( absUrl, options, page, dupCachedPage );
|
||||
},
|
||||
error: function() {
|
||||
error: function( xhr, textStatus, errorThrown ) {
|
||||
//set base back to current path
|
||||
if( base ) {
|
||||
base.set( path.get() );
|
||||
}
|
||||
|
||||
// Add error info to our triggerData.
|
||||
triggerData.xhr = xhr;
|
||||
triggerData.textStatus = textStatus;
|
||||
triggerData.errorThrown = errorThrown;
|
||||
|
||||
var plfEvent = new $.Event( "pageloadfailed" );
|
||||
|
||||
// Let listeners know the page load failed.
|
||||
|
|
|
|||
Loading…
Reference in a new issue