|
方法1:
- $(document).ready(function(){
- $("#submit").on('click', function(){
- var formData = {
- "dAddTS": $('input[name=dAddTS]').val(),
- "sName": $('input[name=sName]').val(),
- "shaoma": $('input[name=shaoma]').val(),
- "sgjc": $('input[name=sgjc]').val(),
- "iAdmin_Id": $('input[name=iAdmin_Id]').val(),
- "iRole": $('input[name=iRole]').val(),
- "dcl": $('input[name=dcl]').val(),
- "iAdmin_CS": $('input[name=iAdmin_CS]').val(),
- "iAdmin_zj": $('input[name=iAdmin_zj]').val(),
- "tgzh": $('input[name=tgzh]').val()
- };
- $.ajax({
- headers: {
- 'Accept': 'application/json',
- 'Content-Type': 'application/json'
- },
- url: '/345345345/xierudaima.asp',
- type : "POST",
- dataType : 'json',
- data : JSON.stringify(formData),
- success : function(result) {
- console.log(result);
- },
- error: function(xhr, resp, text) {
- console.log(xhr, resp, text);
- }
- })
- });
- });
复制代码
方法2:
- <script type="text/javascript">
- $('register_form').on('submit', function(event){
- var obj = $('register_form').serializeJSON();
- $.ajax({
- type: 'POST',
- url: 'https://url.com/users/register',
- dataType: 'json',
- data: JSON.stringify(obj),
- contentType : 'application/json',
- success: function(data) {
- alert(data)
- }
- });
- return false;
- });
- </script>
复制代码
提交数据结果:
|
|