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

相关内容

热门资讯

做出回应!德普之星透视辅助,德... 做出回应!德普之星透视辅助,德普辅助软件,确实确实有挂(有挂规律)1、实时德普之星透视辅助透视辅助更...
总结辅助挂!哈糖大菠萝软件下载... 总结辅助挂!哈糖大菠萝软件下载,智星菠萝有挂吗,本来是真的有挂(有挂功能)1、智星菠萝有挂吗公共底牌...
今日!hardrock作弊,智... 今日!hardrock作弊,智星菠萝有挂吗,真是存在有挂(有挂方式)1、该软件可以轻松地帮助玩家将智...
为了进一步!pokemmo辅助... 为了进一步!pokemmo辅助官网,如何下载德普之星辅助软件,竟然确实有挂(有挂方略)1、上手简单,...
2026版教程!werplan... 您好,德普之星透视这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多玩家在...
2026版教学!wepoker... 2026版教学!wepoker私人局辅助器怎么用,德普之星怎么设置埋牌,本来是真的有挂(真的有挂)该...
攻略辅助挂!hh poker插... 攻略辅助挂!hh poker插件下载,德扑之星透视,切实真的有挂(有挂头条)一、德扑之星透视游戏安装...
刚刚!wepoker究竟有没有... 刚刚!wepoker究竟有没有透视,德普之星私人局透视,一直存在有挂(有挂实锤)1、德普之星私人局透...
2026版软件!wejoker... 2026版软件!wejoker免费脚本,德普之星怎么开辅助,都是是真的有挂(有人有挂)1、许多玩家不...
今年以来!we-poker辅助... 今年以来!we-poker辅助器,德扑之星透视软件免费入口官网,都是确实有挂(有挂教学)德扑之星透视...