rails+jquery confirmation message
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,
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')
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.
精彩评论