Right now, the server response I'm working with sends back a JSON response like this:
{"status":1}
After saving, jeditable places the actual response: {"status":1}
on the page. Anyway to get around this issue?
Right now, the server response I'm working with sends back a JSON response like this:
{"status":1}
After saving, jeditable places the actual response: {"status":1}
on the page. Anyway to get around this issue?
A better solution is to post-process the returned json data before it hits the page.
Suppose your server returns the following json string:
and you would like to process the "status" and "other" fields, and display the "result" field in the jeditable input field.
Add the following 2 lines to jquery.jeditable.js:
(around line 95):
(around line 350, right after " success : function(result, status) {"
Then, in your own code, do something like the following:
This allows you do cool stuff like having your server convert abbreviations to full strings etc.
Enjoy!
This is how I handled the json response.
First, set the datatype using
ajaxoptions
. Then, handle your data in the callback function. Therein,this.revert
is your original value.So the solution I came up with is similar to what madcapnmckay answered here.
Then the url function is
There's a simple way of doing this by using the callback.
.editable()
converts any response to a string, so the response has to be converted to a JSON variable. The values can then be retrieved and then written using a '.text()' method. Check the code: