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

相关内容

热门资讯

透视好友(WPK)总是真的是有... 透视好友(WPK)总是真的是有挂(透视)wpk辅助器(线上教程);该软件可以轻松地帮助玩家将wpk辅...
透视好友房!hhpoker辅助... 透视好友房!hhpoker辅助,hhpoker底牌透视脚本,专业教程(有挂规律);1、该软件可以轻松...
透视教学(WPK)其实真的是有... 透视教学(WPK)其实真的是有挂(透视)wpk辅助器是真的吗(力荐教程);1、下载好wpk辅助器是真...
透视安卓版!hhpoker必备... 透视安卓版!hhpoker必备开挂,hhpoker德州真的假的,软件教程(有挂脚本);1、实时hhp...
透视透视挂(WPK)一直存在有... 透视透视挂(WPK)一直存在有挂(透视)微扑克微乐辅助(分享教程);1、不需要AI权限,帮助你快速的...
透视实锤!hhpoker破解工... 透视实锤!hhpoker破解工具,hhpoker辅助器,新2025版(有挂揭秘);1、用户打开应用后...
透视好友房(WPK)真是有挂(... 透视好友房(WPK)真是有挂(透视)wpk透视辅助靠谱吗(细节揭秘)亲,关键说明,wpk透视辅助靠谱...
透视教学!hhpoker是真的... 透视教学!hhpoker是真的还是假的,hhpoker德州透视挂,安装教程(有挂教程)1、不需要AI...
透视辅助(WPK)其实有挂(透... 透视辅助(WPK)其实有挂(透视)wpk透视是真的吗(曝光教程)1、进入游戏-大厅左侧-新手福利-激...
透视好友!hhpoker辅助软... 透视好友!hhpoker辅助软件是真的么,hhpoker是正规的吗,力荐教程(有挂脚本)1、在hhp...