[jQuery] Re: Determine content type in $.post callback

2009-07-15 Thread bjorsq
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

[jQuery] Re: Determine content type in $.post callback

2009-07-15 Thread dnagir
Hi Peter, Will try tomorrow. I believe this is exactly what I am after. Thanks a lot. Cheers, Dmitriy.

[jQuery] Re: Determine content type in $.post callback

2009-07-14 Thread bjorsq
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:

[jQuery] Re: Determine content type in $.post callback

2009-07-14 Thread dnagir
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.

[jQuery] Re: Determine content type in $.post callback

2009-07-13 Thread dnagir
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

[jQuery] Re: Determine content type in $.post callback

2009-07-13 Thread Peter Edwards
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

[jQuery] Re: Determine content type in $.post callback

2009-07-13 Thread dnagir
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.

[jQuery] Re: Determine content type in $.post callback

2009-07-12 Thread dnagir
Anybody? How can I check the ContentType header in the $.post callback?

[jQuery] Re: Determine content type in $.post callback

2009-07-12 Thread RobG
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

[jQuery] Re: Determine content type in $.post callback

2009-07-08 Thread Giovanni Battista Lenoci
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

[jQuery] Re: Determine content type in $.post callback

2009-07-08 Thread dnagir
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.

[jQuery] Re: Determine content type in $.post callback

2009-07-07 Thread dnagir
Anybody please?

[jQuery] Re: Determine content type in $.post callback

2009-07-07 Thread Cesar Sanz
: Determine content type in $.post callback Anybody please?

[jQuery] Re: Determine content type in $.post callback

2009-07-07 Thread Giovanni Battista Lenoci
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

[jQuery] Re: Determine content type in $.post callback

2009-07-07 Thread dnagir
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) {