码迷,mamicode.com
首页 > Web开发 > 详细

通过form发送xml、json数据

时间:2015-02-06 23:06:42      阅读:207      评论:0      收藏:0      [点我收藏+]

标签:

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

通过form发送xml、json数据

标签:

原文地址:http://www.cnblogs.com/yy2056/p/4278144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!