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私人辅助器,hh poker透视器下载,要领教程(果然是有挂)-哔哩哔哩1、...
透视输赢!德扑圈透视挂(透视)... 透视输赢!德扑圈透视挂(透视)开挂辅助app(竟然真的是有挂)-哔哩哔哩1、德扑圈透视挂ai机器人多...
透视黑科技!智星德州插件,竞技... 透视黑科技!智星德州插件,竞技联盟破解版最新版,操作教程(本来是真的挂)-哔哩哔哩1.竞技联盟破解版...
透视开挂!hhpoker德州机... 透视开挂!hhpoker德州机器人(透视)开挂辅助挂(总是真的有挂)-哔哩哔哩;1、hhpoker德...
透视安装!WePOker有没有... 透视安装!WePOker有没有透视方法,佛手在线是不是有挂,步骤教程(总是存在有挂)-哔哩哔哩1、金...
透视控制!德州局透视脚本免费版... 透视控制!德州局透视脚本免费版下载手机版(透视)开挂辅助器(切实真的是有挂)-哔哩哔哩1、德州局透视...
透视app!hhpkoer辅助... 透视app!hhpkoer辅助器视频(透视)开挂辅助器(原来是有挂)-哔哩哔哩hhpkoer辅助器视...
透视神器!大菠萝手游辅助,hh... 透视神器!大菠萝手游辅助,hhpoker是真的还是假的,课程教程(果然有挂)-哔哩哔哩1、每一步都需...
透视开挂!拱趴大菠萝辅助神器(... 透视开挂!拱趴大菠萝辅助神器(透视)开挂辅助器(切实真的有挂)-哔哩哔哩1、拱趴大菠萝辅助神器系统规...
透视好牌!wpk德州局怎么透视... 透视好牌!wpk德州局怎么透视,wepoker透视辅助下载,手筋教程(总是有挂)-哔哩哔哩1、wep...