[jQuery] ajax: if you don't know the content-type coming back...?
I come from Prototype where javascript returned from an Ajax call is
autoomatically executed. Unfortunately my server side is also sort of
designed on that assumption. So I am POSTing via Ajax and the server
returns text/html on successful validation, application/javascript
only in the event of validation failure. I want javascript to execute
without further ado, but if it's html I want to stick it in a DIV.
So I presume, from reading the docs, that in JQuery I have to use
$.ajax( { // options... }) and use a 'complete' callback in which I
manually check the xmlhttprequest content-type header, and if it's
javascript, eval the responseText, otherwise update my DIV with
responseText.
Is this the correct approach?
Gratefully,
Professor B
http://vernontbludgeon.com/blog/