开发者

rails+jquery confirmation message

开发者 https://www.devze.com 2023-03-26 08:47 出处:网络
i am updating record through jquery, and once data is updated how can one display success/failure 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消