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.
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);
}
You need to return a Json response of the form
{ "Message" = "FOO" }
And that will be displayed in the alert.