I am using jQuery ajax method to get response from my server. Here’s my code:
function getText(id){
$.ajax({
type: 'GET',
url: '/myurl/' + id + '/edit.js',
data: {'id': id},
success: function(data){
alert(data);
},
dataType: 'json'
});
}
I am using ruby on rails, and on my rails controller, I am sending some text as json response. When I check in the firebug, the data is returned correctly. But I don’t get anything with the alert(data); that I have called upon success. Can anyone tell me what’s wrong here? Thanks.
In the alert does it same something like Object object? It should as the data is now a JavaScript object. If you want to see your data, look at the properties, e.g.
alert(data.someProperty).