Friday, February 27, 2009

[jQuery] Re: $.post error on response

Thanks for the quick reply. I tried your code and the alert displays
"[object XMLHttpRequest]". Firebug still doesn't display anything in
the response even though the PHP function is just echoing "checked
out".

On Feb 27, 12:46 pm, MorningZ <morni...@gmail.com> wrote:
> oops.. forgot to change one line
>
> CallParams.data = { imageid: image_id };
>
> On Feb 27, 1:39 pm, MorningZ <morni...@gmail.com> wrote:
>
>
>
> > instead of $.post, try this instead
>
> > var CallParams = {};
> > CallParams.type = "POST";
> > CallParams.url = "your-page.php";
> > CallParams.processData = true;
> > CallParams.data = params;
> > CallParams.dataType = "json";
> > CallParams.success = function(data) {
> >     // "data" is the result};
>
> > CallParams.error = function(x,y,z) {
> >     alert(x);};
>
> > $.ajax(CallParams);
>
> > that will show you what's going on
>
> > On Feb 27, 12:41 pm, Dan <tribaldr...@gmail.com> wrote:
>
> > > I'm using jquery 1.3.2 and trying to send some data using $.post to a
> > > PHP script. For some reason the response is not being returned and
> > > Firebug is reporting an error on line 3633 of jquery.
>
> > > function check_out_image(image_id) {
> > >    $.post('ajax/checkout_image', {imageid: image_id} );
>
> > > }
>
> > > A very simply function that POST's an image ID to my PHP script. The
> > > PHP script is getting run and updating a MySQL database so I know it's
> > > calling the right function and working but the echo response never
> > > makes it back.
>
> > > For reference line 3633 of jquery 1.3.2 is the xhr.send(s.data) line
> > > below:
>
> > >         try {
> > >                 xhr.send(s.data);
> > >         } catch(e) {
> > >                 jQuery.handleError(s, xhr, null, e);
> > >         }
>
> > > For testing purposes I changed my PHP function to a simple echo "foo"
> > > statement with nothing else in it and it still doesn't get returned.
> > > Any ideas on why the response wouldn't get sent back?
>
> > > Thanks,
> > > Dan

No comments: