You don't have any problems here - ajaxSubmit can use all the options that
$.ajax can, so all you need to do is place a complete callback in your
ajaxSubmit options. As far as I can tell from the docs, the complete
callback is your only option as it gets the XHR object as a parameter - but
you
Hi Peter,
Will try tomorrow. I believe this is exactly what I am after.
Thanks a lot.
Cheers,
Dmitriy.
What you need is access to the XMLHttpRequest object used in the request so I
suggest you use $.ajax instead of $.post. The complete callback for $.ajax
receives the XHR and textstatus as parameters, so this should get you the
headers:
Hi,
So the XHR is ONLY available from $.ajax and there's really no way to
get it from methods ($.post)?
I actually need this data in the ajaxSubmit callback of AjaxForm plug-
in.
This sounds like I have no option except to abandon the plug-in and do
the work manually (or modify it)?
Cheers.
Hi Rob,
But I don't see where I can get the XMLHttpRequest objects.
Only one thing related to XHR is this.xhr() function. And it returns a
new XHR object, so obviously it has no headers.
What am I missing?
Cheers,
Dmitriy.
How can I check the ContentType header in the $.post callback?
Try
Hi Dimitriy,
To get the options used by the xhr request (including the ContentType
header), use the this keyword in the callback function:
$.post(url, data, function(){
/* the content of this from a typical $.post operation
this[type]=POST
this[url]=url
this[data]=data
Hi Peter,
var ContentTypeHeader = this.contentType;
this.contentType is the content type of the REQUEST.
I need to get the ContentType of the RESPONSE.
No chance of getting it?
Cheers,
Dmitriy.
Anybody?
How can I check the ContentType header in the $.post callback?
On Jul 13, 9:29 am, dnagir dna...@gmail.com wrote:
Anybody?
How can I check the ContentType header in the $.post callback?
Try the W3C XMLHttpRequest Object specification:
URL:
http://www.w3.org/TR/2006/WD-XMLHttpRequest-20060405/#dfn-getresponseheader
--
Rob
dnagir ha scritto:
Unfortunately I do not see jQuery providing similar function, while
Prototype does:
http://www.prototypejs.org/api/string/isJSON
I've found in the source the function you've linked above, I've rewrited
to make it works with jquery:
jQuery.isJson = function(str) {
if
Hi Guys,
Thanks a lot. Both eval and prototyp-ish ways are ok.
Another question on this.
The server returns ContentType header with value application/json.
How can check this in the callback of the $.post function?
I just don't see ContentType in any properties of this.
Cheers,
Dmitriy.
Anybody please?
: Determine content type in $.post callback
Anybody please?
dnagir ha scritto:
Anybody please?
if(typeof(ret_data) == 'object') {
}
or if it's not evalueated by jquery try to eval with a try/catch block.
:-)
--
gianiaz.net - web solutions
via piedo, 58 - 23020 tresivio (so) - italy
+39 347 7196482
The type of the data is always string. I also cannot specify the
dataType. If it will be different (HTML instead of JSON) jQuery fails
silently.
I made a litle function to check the string if it HTML or JSON.
It works so far, but is totally inelegant:
this.isJsonStr = function(str) {
15 matches
Mail list logo