jQWidgets Forums

jQuery UI Widgets Forums Grid 403 Error not being caught

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 11 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • 403 Error not being caught #50743

    EvilGenius
    Participant

    Hey,

    Started using jqWidgets and have enjoyed them so far. I’ve run into a bit of a problem catching a 403 error and handling it though. I’ve got a page with a Grid widget that uses a DataAdapter to make a call to a PHP service to get a JSON string of the data it is to display. Not an unusual arrangement and easy to implement. However, the PHP service does require that the user be logged in to use it. So, it is throwing a 403 Forbidden Error. Once again, not unusual and expected. However, what is unexpected is that the Grid hangs up with a little “Loading…” window. I’ve attempted to catch the error and handle it in the following ways…

    
    var dataAdapter = new $.jqx.dataAdapter(source, {
    		downloadComplete: function (data, status, xhr) 
    		{ 
    			alert("Download complete!");
    		},
    		loadComplete: function (data) 
    		{
    			alert("Load complete!");
    		},
    		loadError: function (xhr, status, error) 
    		{
    
    			alert("Load Error!");
    		}
    	});
    

    None of the above events fires. I’ve also tried setting the jQuery ajaxSetup in order to handle the situation like thus..

    
    $.ajaxSetup(
        {
            error: function (x, status, error) {
    		alert("Error!");
    			if (x.status == 403) {
    				alert("Sorry, your session has expired. Please login again to continue");
    			}
    			else {
    				alert("An error occurred: " + status + "nError: " + error);
    			}
    	}
    });
    

    But that doesn’t fire either.

    I am obviously missing something. Is there an event that I should be using that I’m not seeing?

    I’m using…
    jQuery 2.0.2
    jqWidgets 3.2.1
    Chrome 33.0.1750.146 m

    Any help would be appreciated.

    Thanks,
    Andrew

    403 Error not being caught #50745

    Peter Stoev
    Keymaster

    Hi Andrew,

    If there is a binding error, the loadError callback function would be called. Internally, we use the jQuery’s Ajax function so if it does not throw an error, we do not know what could be the problem’s reason. My guess is that the invalid sessions should be handled on the server side in some way, i.e return some output which is handled in specific way from the client.

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.