0

In my rails app I need to send data from client to server via json request, method: POST. But client sends data with GET method.

server: nginx

client:

   $.ajax({
      url: "http://myurl",
      type: "POST",
      data: mydata,
      dataType: "script"
    });

In browser console I can see:

Request URL:    http://myurl?my_data
Request Method: GET
Status Code:    HTTP/1.1 404 Not Found

Nginx config:

upstream appname {
  server unix:///tmp/appname.sock;
}

server {
  listen 80;
  server_name app_url; 
  root /var/www/appname/current/public; 
  location / {
    proxy_pass http://appname; 
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  }

  location ~* ^/assets/ {
    expires 1y;
    add_header Cache-Control public;
    add_header Last-Modified "";
    add_header ETag "";
    break;
  }
}
Efremov
  • 127
  • 1
  • 8
  • Maybe it's just no good, but try altering the order of your params in the ajax call like this: type, datatype, url, data – Ruby Racer Mar 22 '14 at 20:56
  • That URL looks different too, are you sure there aren't any other ajax call on some even on this element? – vee Mar 22 '14 at 22:30

1 Answers1

0

Not sure why your current method doesn't work. But you can try this

$.post( "http://myurl", mydata );
usha
  • 28,973
  • 5
  • 72
  • 93