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

相关内容

热门资讯

透视技法!wepoker有机器... 透视技法!wepoker有机器人吗(WPK俱乐部)本来有辅助攻略(哔哩哔哩)1、不需要AI权限,帮助...
透视模块!wepoker私人局... 透视模块!wepoker私人局透视方法(AApoker安全)其实真的有辅助脚本(哔哩哔哩)一、wep...
透视讲义!wepoker透视最... 透视讲义!wepoker透视最简单三个步骤(WePoKer内购)一直真的有辅助脚本(哔哩哔哩)1、超...
透视经验!hhpoker为什么... 透视经验!hhpoker为什么一直输(WePoKer用挂)总是真的有辅助神器(哔哩哔哩)1、hhpo...
透视资料!拱趴大菠萝万能辅助器... 透视资料!拱趴大菠萝万能辅助器(透视)约局吧能不能开挂(辅助)竟然存在有app(哔哩哔哩)1、玩家可...
透视窍门!pokemmo脚本辅... 透视窍门!pokemmo脚本辅助器下载(透视)epoker底牌透视(辅助)总是一直都是有攻略(哔哩哔...
透视举措!wepoker安装教... 透视举措!wepoker安装教程(WePoKer好牌)真是存在有辅助软件(哔哩哔哩)1、在wepok...
透视教程书!菠萝德普辅助器免费... 透视教程书!菠萝德普辅助器免费版在哪里(透视)来玩app破解版(辅助)本来一直都是有方法(哔哩哔哩)...
透视妙计!wepoker俱乐部... 透视妙计!wepoker俱乐部辅助器(AApoker免费)确实真的是有辅助方法(哔哩哔哩)1、wep...
透视机巧!智星德州插件怎么下载... 透视机巧!智星德州插件怎么下载(透视)佛手在线是不是有挂(辅助)都是存在有教程(哔哩哔哩)1、首先打...