如何摆脱jQuery(可编辑的)混乱 [英] how to get out of jquery (jeditable) mess

查看:58
本文介绍了如何摆脱jQuery(可编辑的)混乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太擅长jQuery,但决定为我的网站使用 jEditable 插件,因为我认为它看起来不错并解决了目的.但是,我现在有点纠结.

I am not very good at jQuery but decided to use jEditable plugin for my site because I thought it looked good and solved the purpose. However, I am in a bit of a tangle now.

我使用了此插件来编辑数据,然后将编辑后的数据发送到数据库,并由它更新某些字段.更新这些字段的存储过程将返回一些数据.我想把这些数据还给我.我只想先在"alert"语句中查看返回的数据,然后再从那里获取数据.

I used this plugin to edit data and the edited data is sent to the DB and some fields are updated by it. the Stored procedure that updates these fields is returning some data back. I would like to have this data returned back to me. I would just like to see the returned data in an 'alert' statement first, then I can take it from there.

此插件的回调方法仅具有值和设置.

The callback method of this plugin just has value, and settings.

在使用此插件时,有什么方法可以从服务器端获取一些数据吗?

Is there any way to get some data back from the server-side while using this plugin?

推荐答案

我已经为我的网站完成了此操作.这应该可以帮助您入门.

I have done exactly this for my site. This should get you started.

$("#editable_text").editable(submitEdit, { 
            indicator : "Saving...",
            tooltip   : "Click to edit...",
            name : "Editable.FieldName",
            id   : "elementid",
            type : "text",
});
function submitEdit(value, settings)
{ 
   var edits = new Object();
   var origvalue = this.revert;
   var textbox = this;
   var result = value;
   edits[settings.name] = [value];
   var returned = $.ajax({
           url: "http://URLTOPOSTTO", 
           type: "POST",
           data : edits,
           dataType : "json",
           complete : function (xhr, textStatus) 
           {
               var response =  $.secureEvalJSON(xhr.responseText);
               if (response.Message != "") 
               {
                   alert(Message);
               } 
           }
           });
   return(result);
 }

您需要返回以下形式的Json响应

You need to return a Json response of the form

{"Message" ="FOO"}

{ "Message" = "FOO" }

这将显示在警报中.

这篇关于如何摆脱jQuery(可编辑的)混乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆