I’m making the following cross-domain post, which hits my Rails app no problem. I get a response back, and it is the response I expect. Except that the “weight: 20” has not been taken into account by my app. I am using CORS to make the request, and in particular I am using the rack-cors gem.
$.ajax({
url: "http://localhost:3000/australia_post_api_connections",
type: "GET",
data: { weight: 20 },
dataType: 'json',
crossDomain: true,
xhrFields: {
withCredentials: true
},
success: function(data) {
console.log("success");
$('#shipping-calculator').html(data);
}
}).fail(function() { console.log("fail") })
.always(function() { console.log("always") })
.complete(function() { console.log("complete") });
Am I making a very simple mistake in my JSON, or am I failing to include some CORS related stuff? This tutorial mentions Access-Control-Allow-Headers and Access-Control-Request-Headers. Might that have something to do with it?
Thanks
z.
try appending the weight:20 tot he url so it looks like this
“http://localhost:3000/australia_post_api_connections?weight=20”
or you could do this to the data