jQuery: The Write Less, Do More JavaScript Library

 « Return to Thread: ajax post not sending header

Re: ajax post not sending header

by James-279 :: Rate this Message:

Reply to Author | View in Thread


Have you tried using Firebug for Firefox to examine the headers of the
AJAX request to be sure that it wasn't sent? Check that first.

You might be reading the headers incorrectly on the PHP side. Are you
using: $_SERVER['HTTP_X_REQUESTED_WITH']
The beginning HTTP_ part is the tricky part. Make sure you have that.

On Jun 30, 9:52 pm, hadaraz <hada...@...> wrote:

> Posting data from a form using this function:
>
> $(function() {
>     $('#emailform').submit(function() {
>         $.ajax({
>             url: '/post/url/',
>             dataType: 'json',
>             data: $('#emailform').serialize(),
>             success: function(rdata) {
>                 $('#emailformmessage').text(rdata.message).show
> ('slow');
>             }
>         });
>     });
>     return false;
>
> });
>
> the server doesn't detect an ajax call ('X-Requested-With' header is
> not sent). I tried forcing it with beforeSubmit and also with
> ajaxSetup,  but no go.
> Any solutions to this problem?
>
> hadaraz

 « Return to Thread: ajax post not sending header