JQUERY,AJAX,POST方法错误

I am trying to make JQUERY ajax call using method post with the following code snippet, But the call is not making to server and receiving error .. No 'Access-Control-Allow-Origin' header is present on the requested resource.

We added these headers on the server side code based on the suggestions i see from various posts. no luck there. I added headers on the clinet side too. I am trying from my local machine to the server in the dev environment. Another request with get is working fine and i have issues with only post. I tried JSON.stringify for the data and no luck there.

 $.ajax({
    url: ttsCreateURL,
    type: "POST",
    dataType: 'json',

    crossDomain: true,
    data: { "ballotId" : "0" ,"conMonth": "JUN2014","empId":"9999","airlineCode":"AA", "createdDate":"" },

    success: function(response){            
               alert(response);

    },
    error:function(xhr, ajaxOptions, thrownError){
        //ajaxError("There was an error .  Please try again.",xhr, ajaxOptions, thrownError);
         $('#Main').load('error.html');
    }   
  });

When i try to see the url in the browser along with query string params i see Error 415: Unsupported Media Type error.

Change dataType="jsonp" and use callback in the server side.

If you really want to use CORS and not JSONP, here are some hints for cross-origin-request trouble-shooting:

  1. Obviously the Access-Control-Allow-Origin is missing. Make sure your server always sets the correct response headers. Use a local webproxy to find this out for sure. On Windows I am using Fiddler. On Linux, I think Wireshark works.
  2. Adding headers on the client side won't help. If you found that your server does not add the headers, e.g. because it's treating POST differently, change either you client code to trigger the server adding the headers or change the server to reply properly.
  3. Beware of Preflighted requests. If you modify the request headers client side, such a request may be issued. It will be sent without any of the other POSTed information (i.e. without POST body). Include the Access-Control-Allow-Methods header [with POST, obviously] as well as the other Access-Control*-headers with your response to such an OPTIONS request.
  4. If you send withCredentials (not given in the sample, though), the Access-Control-Allow-Origin header must not be a wildcard.

As you are writing that when requesting the URL in your browser, you get a 415 error, look up what this particular server expects. By default jQuery URL-encodes your request (application/x-www-form-urlencoded) data when using $.ajax. HTTP status code 415 means that your client sent something the server does not like to work with. If the server bails out with the 415 on your POST as well, it is not too surprising if there is no Access-Control-Allow-Origin header as often not present in error handlers.