0

I have some tabs that I load the content up via ajax. I am wondering is there away to look at the response of the ajax call before it loads the content into the tabs?

I want to see if any errors occurred. For instance the tab contents might need the users Id but for some reason that was null. In my code that I have I have stuff that actually checks for these things and if this happens puts it in a validation error.

I usually return the errors back as a json result and use a dialog box to display the error.

So I would like to check the ajax call from the tab and see if it is a validation error(json response) and if has validation errors stop loading the tab and popup a dialog box.

So does jquery ui tabs have something like this? Or do I have to use http status code and set a status code error?

1 Answer 1

1

You can use the ajaxOptions to supply a complete function which will allow you to look inside the response. The exact args passed to the complete event depend on which version of jQuery you are using.

function checkResponse(args){

   //interrogate the response and decide what to show the user

}

$( ".tabs" ).tabs({ ajaxOptions: { complete: checkResponse } });
Sign up to request clarification or add additional context in comments.

2 Comments

I am using 1.5. So will the data be loaded into the tab at this point?
@chobo2 - not at the complete stage, The tabs use the success event to populate the contents.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.