<p>I have a controller that returns either JSON or partial html depending on if the user is logged in. </p>

<p>Is there anyway to tell the difference once the result has been returned??
What is the best way.</p>

<p>Obviously i have different actions to complete if the response is json or if it is the partial html. With the json one i do a redirect to the login page, and with the html one i just display it. If only i could render the html server side and send it back in json format?? From what i have heard this cannot be done as yet. Thoughts?</p>

<p>Cheers.</p>

<p><strong>DUPLICATE: <a href="https://stackoverflow.com/questions/291466/can-i-evaluate-the-response-type-of-an-ajax-call-in-success-callback">Can I evaluate the response type of an $.ajax() call in success callback?</a></strong></p>

I'd say, assuming you have control of the thing returning JSON or partial HTML, that you should change the Content-Type header of the JSON result to something like
```
application/x-format-json
```
or an equally obvious type.