通过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

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。