ASP.NET:Ajax不发送字符串
创始人
2024-09-20 00:00:57
0
  1. 确保使用的是POST方法

    function sendData(strData) { $.ajax({ type: "POST", url: "MyApiUrl", data: strData, contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { console.log(response); }, error: function (xhr, ajaxOptions, thrownError) { console.log(xhr.status); console.log(thrownError); } }); }

  2. 设置content-type为application/json,并将data参数转换为JSON字符串

    function sendData(strData) { $.ajax({ type: "POST", url: "MyApiUrl", data: JSON.stringify(strData), contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { console.log(response); }, error: function (xhr, ajaxOptions, thrownError) { console.log(xhr.status); console.log(thrownError); } }); }

  3. 如果仍然无法发送字符串,请尝试使用XMLHttpRequest对象手动发送

    function sendData(strData) { var xhr = new XMLHttpRequest(); xhr.open('POST', 'MyApiUrl', true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { console.log(xhr.responseText); } }; xhr.send(strData); }

相关内容

热门资讯

九分钟教学!呼兰麻将有挂么,w... 九分钟教学!呼兰麻将有挂么,wopoker真的有挂(详细透视辅助神器教程);wpk透视辅助官方版是专...
6分钟规律!闲来跑胡子辅助工具... 6分钟规律!闲来跑胡子辅助工具,fish poker外 挂(详细透视辅助助手教程);闲来跑胡子辅助工...
一分钟透明!丫丫衡阳字牌有挂吗... 1、一分钟透明!丫丫衡阳字牌有挂吗,云扑克辅助器真假(详细透视辅助挂教程)。2、丫丫衡阳字牌有挂吗透...
3分钟介绍!同城上饶棋牌有挂吗... 3分钟介绍!同城上饶棋牌有挂吗,wpk脚本(详细透视辅助软件教程)1、很好的工具软件,可以解锁游戏的...
6分钟方法!家家盘锦麻将有挂吗... 6分钟方法!家家盘锦麻将有挂吗,wpk微扑克真的有辅助插件(详细透视辅助黑科技教程);原来确实真的有...
7分钟规律!开心联盟牛牛有没有... 7分钟规律!开心联盟牛牛有没有外 挂,德州ai辅助代理(详细透视辅助工具教程)准备好在开心联盟牛牛有...
6分钟攻略!越乡游斗牌辅助,微... 6分钟攻略!越乡游斗牌辅助,微扑克被系统制裁(详细透视辅助脚本教程)是一款可以让一直输的玩家,快速成...
7分钟技巧!心悦填大坑辅助器,... 7分钟技巧!心悦填大坑辅助器,aapoker发牌机制(详细透视辅助神器教程);科技安装教程;1367...
六分钟介绍!沐沐福建麻将app... 六分钟介绍!沐沐福建麻将app有猫腻吗,德州之星软件(详细透视辅助工具教程)是由北京得沐沐福建麻将a...
1分钟技巧!顺心茶楼外 挂,a... 1分钟技巧!顺心茶楼外 挂,aapoker外 挂实测(详细透视辅助挂教程);一、顺心茶楼外 挂AI软...