Yeah I can do something similar with PHP's  die()  function.  Of
course, it won't let me set the status code to 500, and also put the
error message in the die() function.

Thanks for the reply.  Anybody else?

Jamie

On Aug 21, 2:02 pm, MorningZ <morni...@gmail.com> wrote:
> I'm no PHP expert, or even a novice for that matter....
>
> but in ASP.NET saying the line
>
> Throw New Exception("This is a server side error")
>
> the value in that jQuery error function "xhr" has that text inside
> xhr.responseText (along with the rest of the HTML that .NET generate,
> but I just pull out between the <title></title> tags)
>
> so, if i have
>
> $.ajax(
>        type: "POST",
>        url: "foo.ashx",
>        processData: true,
>        data: { a: 1, b: 2},
>        dataType = "json",
>        success: function(json) {
>           // do something with returned JSON
>        },
>        error: function(xhr, status, exception) {
>           // xhr.responseText has the HTML of the page the server side
> error created
>          //  the actual error is inside <title></title> in an ASP.NET
> enviroment
>        }
> );
>
> That's how i have been handling server side stuff for quite a while
> now anyways
>
> $.ajax(
>    "foo.ashx",
>    {  parameters
>
> On Aug 21, 1:50 pm, livefree75 <jpittm...@gmail.com> wrote:
>
> > Hi,
>
> > I've been using $.get() and $.post() extensively, but then noticed teh
> > more functional $.ajax, which lets you handle server-side errors using
> > the "error" option.
>
> > The parameters to the callback function for the error option are:
> > (xhr, status, exception), where in the documentation it says
> > "exception" is the Exception object if it's supplied.
>
> > My server-side is PHP, and when I perform a:
> >      throw new Exception("You can't do that!")
> > or
> >      trigger_error("You can't do that!", E_USER_ERROR)
>
> > it does run my error callback, but it puts 'undefined' in the
> > "exception" object, and my custom error message is nowhere to be
> > found.
>
> > So the question is, how do I populate that Exception object on the
> > server side, so that the error callback can then access it?
>
> > Thanks,
> > Jamie

Reply via email to