The GetEventList method seems to work consistantly when the page is initially loaded, but when it is called occassionally to refresh the page, one of the methods GetEventList calls to collect it's data returns empty, causing it to appear as if there are
no events. It's not a timeout error, because the line it displays when there are no events appears, so the method is still returning a value to the AJAX call.
I'm not sure how to troubleshoot this. You can see what I'm talking about here: http://ccchapel.com/New-Calendar/#!/2012/6/. When you intially go to the page, it will load. Click Next/Previous and get back to June and it will usually just say: "Sorry, but
it looks like there are no events currently scheduled for June 2012."
Again, the AJAX call is completing, but it seems like a specific method isn't completing consistantly.
Does any of this make sense? I'm stumped on this one and need to get this working.
Any help would be greatly appreciated. I can provide more details about what's going on behind the scenes if needed.
Not sure what your problem is, but one suggestion: Don't do the JSON encoding yourself -- you're doing a bunch of strng concatenations to construct the JSON and it seems error prone if not tedious. So you can do this instead (which looks very similar, but
it's slightly different):
var data = { _month : month, _year : year, _currentCampus : currentCampus, _ministry : ministry };
var json = JSON.stringify(data);
var request = $.ajax({
type : "POST",
data : json,
....
});
So the point is that you create the data and let the runtime APIs do the proper JSON formatting.
I'll admit, I'm not sure where to plug in the error handler in this scenario since it's a JavaScript thing. I'm seeing no errors from Firefox's Error Console.
It never fires, though. The success method does. So the AJAX call isn't erroring. It almost seems server-side that is erroring, but also not getting any errors on that.
Ok... I guess I have to play around with it more. I guess what I don't get is that my WebMethod basically makes a few function calls to collect and process data, but it's like one of those calls stalls out and quits prematurely, but it's not throwing an
error.
I'd be interested to hear if anyone else has any insights?
At this point, I'm wondering if my best bet is to force a server-side load when this scenerio or other error occurs.
Oh... Maybe it's also worth asking, but I saw this post: http://forums.asp.net/t/1484657.aspx. I didn't know that ASP had it's own JSON limit. Could that be what's happening? Wouldn't that throw a JavaScript error, though?
airic82
Member
78 Points
223 Posts
AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 03:24 PM|LINK
Hi!
I think I know what's going on, but I'm not sure. I'm making an AJAX call using jQuery to a WebMethod:
var request = $.ajax({ type: "POST", timeout: 100000000, url: "/CMSTemplates/ChristCommunityChapel/PublicCalendar.aspx/GetEventsList", data: "{ '_month' : '" + month + "', " + "'_year' : '" + year + "', " + "'_campusName' : '" + currentCampus + "', " + "'_ministry' : '" + ministry + "' } ", contentType: "application/json; charset=utf-8", dataType: "json" });The GetEventList method seems to work consistantly when the page is initially loaded, but when it is called occassionally to refresh the page, one of the methods GetEventList calls to collect it's data returns empty, causing it to appear as if there are no events. It's not a timeout error, because the line it displays when there are no events appears, so the method is still returning a value to the AJAX call.
I'm not sure how to troubleshoot this. You can see what I'm talking about here: http://ccchapel.com/New-Calendar/#!/2012/6/. When you intially go to the page, it will load. Click Next/Previous and get back to June and it will usually just say: "Sorry, but it looks like there are no events currently scheduled for June 2012."
Again, the AJAX call is completing, but it seems like a specific method isn't completing consistantly.
Does any of this make sense? I'm stumped on this one and need to get this working.
Any help would be greatly appreciated. I can provide more details about what's going on behind the scenes if needed.
Thanks!
-Eric
BrockAllen
All-Star
28072 Points
4996 Posts
MVP
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 03:28 PM|LINK
Not sure what your problem is, but one suggestion: Don't do the JSON encoding yourself -- you're doing a bunch of strng concatenations to construct the JSON and it seems error prone if not tedious. So you can do this instead (which looks very similar, but it's slightly different):
var data = { _month : month, _year : year, _currentCampus : currentCampus, _ministry : ministry }; var json = JSON.stringify(data); var request = $.ajax({ type : "POST", data : json, .... });So the point is that you create the data and let the runtime APIs do the proper JSON formatting.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
bruce (sqlwo...
All-Star
37614 Points
5573 Posts
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 03:31 PM|LINK
also you should add an error handler so you can see what error the server is returning.
airic82
Member
78 Points
223 Posts
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 03:59 PM|LINK
Bruce:
I'll admit, I'm not sure where to plug in the error handler in this scenario since it's a JavaScript thing. I'm seeing no errors from Firefox's Error Console.
Can you maybe provide a bit more information?
Thanks!
airic82
Member
78 Points
223 Posts
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 03:59 PM|LINK
Brock:
Thanks! I'll give that a try and see if it makes a difference.
bruce (sqlwo...
All-Star
37614 Points
5573 Posts
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 05:11 PM|LINK
try reading the jquery docs for $.ajax. as stated, without a fail handler there is no error reporting.
airic82
Member
78 Points
223 Posts
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 06:15 PM|LINK
I have that built in. Sorry I didn't mention it:
request.fail(function(jqXHR, textStatus) { alert("Request failed: " + textStatus); });It never fires, though. The success method does. So the AJAX call isn't erroring. It almost seems server-side that is erroring, but also not getting any errors on that.
BrockAllen
All-Star
28072 Points
4996 Posts
MVP
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 29, 2012 06:24 PM|LINK
So to diagnose the problem:
1) Do a network trace (with Fiddler or the network tab from your browser's dev tools) to see what's being sent back and forth
2) Put a breakpoint in your success event handler and look at the xhr object for status and other properties to help provide insight into the problem.
DevelopMentor | http://www.develop.com
thinktecture | http://www.thinktecture.com/
airic82
Member
78 Points
223 Posts
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 30, 2012 12:01 AM|LINK
Ok... I guess I have to play around with it more. I guess what I don't get is that my WebMethod basically makes a few function calls to collect and process data, but it's like one of those calls stalls out and quits prematurely, but it's not throwing an error.
I'd be interested to hear if anyone else has any insights?
At this point, I'm wondering if my best bet is to force a server-side load when this scenerio or other error occurs.
Thanks!
airic82
Member
78 Points
223 Posts
Re: AJAX Call Not Completing, But Not Throwing Error Either
Mar 30, 2012 12:02 AM|LINK
Oh... Maybe it's also worth asking, but I saw this post: http://forums.asp.net/t/1484657.aspx. I didn't know that ASP had it's own JSON limit. Could that be what's happening? Wouldn't that throw a JavaScript error, though?
Thanks!