What if we changed the JSON part of the httpData function from:

// Get the JavaScript object, if JSON is used.
if ( type == "json" )
    data = window["eval"]("(" + data + ")");


to:


// Get the JavaScript object, if JSON is used.
if ( type == "json" || !type && ct && ct.indexOf("json") >= 0)
    data = window["eval"]("(" + data + ")");


It's been quite helpful to me indeed, i.e., in implementing a
classical "client submits form" ---> "server processes form" --->
"server returns content (form errors) or redirect (no errors)"
approach within tabs, greatly speeding development time:


$.ajax({
    type: "POST",
    url: "/mformprocessor",
    data: $("#mform").serialize(),
    success: function(resp){
        if (!empty(resp.redir) {
            redirTab(resp.redir, TABS_CONTAINER_ID, 2);
        } else {
            setTabHTML(resp, TABS_CONTAINER_ID, 2);
        }

    }
});


This affords the server the ability to effect varying actions on the
client without worrying about output buffering (resp.html) and other
headache inducers. Plus, I think it's a good idea to treat the
response as json if the content-type header is json.

Might something like this be committable?




On Dec 22, 1:19 pm, webbiedave <webbied...@hotmail.com> wrote:
> Hello.
>
> Could we change the $.ajax() function to treat the server's response
> as json if dataType is unspecified and the response content-type is
> "application/json"?
>
> Thanks,
> Dave

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to