通过form发送xml、json数据

The best way I can think of is to intercept the form-submit action, and convert the form details into XML format, and then submit that to the server. There are many ways to do this, but the easiest would be to implement a solution via a framework like jQuery:

An example of this very thing can be found online at http://www.docunext.com/...data-to-xml-with-jquery which utilizes the JSON to XML Plugin:

 

$("#myform").submit(function(){
  var formjson = $('#myform').serializeArray();
  var formxml = json2xml(formjson);
  $.post("/collect.php", { 'data': formxml }, function(data){
    // callback logic
  });
  return false;
});

 

来自 <http://stackoverflow.com/questions/2088862/how-to-post-xml-to-server-thru-html-form

你可能感兴趣的:(json)