jquery - JS Fiddle JSON/ECHO returning empty object -


i learning ajax, jquery , json.

i have following js fiddle sending request json/echo , response empty object. can tell me doing wrong?

http://jsfiddle.net/deandalby/7a2t0eb5/3/

var saveurl = "http://fiddle.jshell.net/echo/json/";  $(document).ready(function () {     $("#savebutton").click(function () {         save();     }); });  function getpersondetails() {     var arrayx = $(":input").serializearray();     var json = {};     jquery.each(arrayx, function () {         json[this.name] = this.value;     });      writetodom('formatted json', json.stringify(json, null, 4));      return json; }  function save() {     var data = getpersondetails();      $.ajax({       url: saveurl,       datatype: "json",       data: data,       type: "post",       cache: false,       success: function (response) {             writetodom('plain response', json.stringify(response));         writetodom('formatted response', json.stringify(response, null, 4));       },       error: function (response) {         alert("error");       },       complete: function () {         writetodom("complete", "");       }     }); }  function writetodom(title, content) {     $("form").append("<div class='alert alert-success' role='alert'>" + title + ":</div><div><pre>" + content + "</pre></div>"); } 

in order jsfiddle echo ajax working have send data string. in addition path /echo/json/ post key json , string value

change

var data = getpersondetails(); 

to

var data = {json: json.stringify(getpersondetails())}; 

if working html be:

var data ={ html:'<p>some text</p>'}; 

and path /echo/html/

demo


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -