$.ajax() complete parms undefined and timeout problem
I have what I think is a simple $.ajax() call. I added complete and error functions but a time out in firefox 3.5.2 doesn't cause the error function to be called and when the complete function is called both parameters are undefined. If I make the ajax call return a http 500 response the error function is called.
My code is -
$(document).ready(function() {
$('#btnNext').click(function(event) {
try {
var pageUrl = $(this).attr('href');
var splitter = new Array();
splitter = pageUrl.split('/');
var id = splitter[splitter.length - 2];
var pageNo = splitter[splitter.length - 1];
var dataUrl = '/Home/ForumThreads/' + id + '/' + pageNo;
jQuery.ajax({
type: 'GET',
cache: false,
url: dataUrl,
jsonp: 'method',
dataType: 'jsonp',
data: '{}',
timeout: 1000,
success: function(data) {
var totalCount = data.TotalCount;
$('#forumpostlist').empty();
$.each(data.ForumPosts, function(forumIndex, forumPost) {
var html = '<div class="forumpost">';
html += '<h3>' + forumPost.Title + '</h3>';
html += '<p>' + forumPost.Body + '</p>';
html += '<p>Added By ' + forumPost.AddedByName + ' on ' + forumPost.AddedDate + '</p>';
html += '</div>';
$('#forumpostlist').append(html);
});
$('#totalCount').text(totalCount);
},
complete: function(xhr, textStatus) {
// Create btnNext/btnPrev as appropriate.
},
error: function(xhr, ajaxOptions, thrownError) {
window.location = '/UGC/Browse/' + id + '/' + pageNo;
}
});
return false;
}
catch (err) {
return true;
}
})
});
Running on FF 3.5.2, JQuery 1.6.2 on XP Pro.
Thanks in advance.
Steve.