I have made an ajax post request for json data and I want to access that data in the rails controller so how can I access the data.
Here is how I posted the data using a
You dont need to define type json in your jquery ajax post request. use below code in your javascript
jQuery.ajax({
url: 'main/getlocation',
data: {latitude:latitude,longitude:longitude},
type: "POST",
success: function(data) {
alert("Successful");
},
failure: function() {
alert("Unsuccessful");
}
});
and now try
params[:latitude] and params[:longitude] in your controller.