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); }

相关内容

热门资讯

第三方技巧!hhpoker破解... 第三方技巧!hhpoker破解工具,德普辅助软件,原来真的有挂(有挂秘笈)1、打开软件启动之后找到中...
总算了解!hhpkoer辅助挂... 总算了解!hhpkoer辅助挂是真的吗,wepoker有机器人吗,其实是真的有挂(有挂攻略)1、完成...
随着!竞技联盟透视,德普之星怎... 随着!竞技联盟透视,德普之星怎么设置埋牌,本来是有挂(果真有挂)该软件可以轻松地帮助玩家将德普之星怎...
推荐一款!aapoker怎么设... 推荐一款!aapoker怎么设置提高好牌几率,wepoker免费钻石,一贯真的有挂(真实有挂)是不是...
有玩家发现!we poker辅... 有玩家发现!we poker辅助器,德普之星透视辅助软件是真的吗,一直真的是有挂(有挂方略)1、这是...
避坑细节!epoker底牌透视... 避坑细节!epoker底牌透视,hhpoker免费透视脚本,切实是真的有挂(有挂方略)在进入软件靠谱...
总结辅助挂!wepoker透视... 总结辅助挂!wepoker透视底牌,德普之星透视辅助软件,其实真的是有挂(有挂存在)1、进入游戏-大...
来一盘!wepoker智能辅助... 来一盘!wepoker智能辅助插件,wpk透视是真的吗,真是是真的有挂(有挂助手)1、下载好wepo...
备受关注的!hhpoker辅助... 备受关注的!hhpoker辅助器视频,红龙poker辅助,果然存在有挂(有挂方法)1、玩家可以在红龙...
专业讨论!aapoker插件下... 专业讨论!aapoker插件下载,约局吧开挂神器是真的吗,其实真的有挂(真的有挂)1、专业讨论!aa...