Reputation: 1441
i am updating record through jquery, and once data is updated how can one display success/failure message.
i have used following code to update data through jquery,
var data = {user_id:userId, user_type:$("#userType").val()};
var url = "<%= url_for(updateUser_path)%>";
$.get(url, data)
thanks,
Upvotes: 0
Views: 104
Reputation: 5104
In addition to the answer about json, if you want to integrate more tightly with rails you should check out unobtrusive javascript, and use it in conjunction with a :remote => true form.
Upvotes: 0
Reputation: 640
Respond with json once you update data, and then process normally with jquery, for example:
$.get(url, data, function(resp_data){
if (resp_data.status == 'ok') {
alert(resp_data.ok_msg)
} else {
...
}
...
}, 'json')
Upvotes: 2