I also deal with JSON almost exclusively (albiet in .NET, but getting
the server side error would be the same)

since $.getJSON doesn't handle error events, I wrote this simple
wrapper around the $.ajax function

GetAjax = function(url, params, success, error) {
    var CallParams = {};
    CallParams.type = "POST";
    CallParams.url = url;
    CallParams.processData = true;
    CallParams.data = params;
    CallParams.dataType = "json";
    CallParams.success = success;
    if (error) {
        CallParams.error = error;
    }
    $.ajax(CallParams);
}


so now I could say:

var Params = {};
Params.ID = 4;
Params.Name = "Steve";

AjaxGet(
     "some url",
     Params,
     function(json) {
           //with success, 'json' is my result
     }
     function(x,y,z) {
          //on error, x.responseText has the server error result
     }
);

hope that helps


On Jun 14, 12:31 pm, Peter Marino <marino.pe...@gmail.com> wrote:
> Hi jQuery,
> I'm using the $.ajax method and when this errors I react to the error event
> within and dump
> the XMLHttpRequest, textStatus, errorThrown to get an idea of what when
> wrong... but
> the most common message is "parse error" which doesn't help me that much.
>
> what is going wrong is that on the server side my php file has errors in it
> and I would like
> to see the errors on the client side.
>
> so basically is there a way to dump the result the server sends back that
> $.ajax does not
> know how to handle. btw: my $.ajax is setup to use json and this is probably
> why it fails...
> but I would like to see the result from the server.
>
> is this possible?
> anyone?
>
> --
> Power Tumbling -http://www.powertumbling.dk
> OSG-Help -http://osghelp.com

Reply via email to