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

相关内容

热门资讯

透视智能ai!we poker... 透视智能ai!we poker辅助器,wepoker怎么看底牌,举措教程(本来真的是有挂)-哔哩哔哩...
透视私人局!德州局透视脚本免费... 您好,德州局透视脚本免费版下载手机版这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704...
透视透视挂!wepoker辅助... 透视透视挂!wepoker辅助器是真的吗,哈糖大菠萝免费辅助器,资料教程(竟然是有挂)-哔哩哔哩1、...
透视新版!wepoker怎么买... 透视新版!wepoker怎么买辅助,wepoker分析,机巧教程(真是真的有挂)-哔哩哔哩1、进入游...
透视计算!拱趴大菠萝挂,aap... 透视计算!拱趴大菠萝挂,aapoker怎么设置提高好牌几率,步骤教程(本来存在有挂)-哔哩哔哩1、任...
透视挂!wejoker内置辅助... 透视挂!wejoker内置辅助(透视)开挂辅助技巧(本来真的是有挂)-哔哩哔哩1、wejoker内置...
透视插件!哈糖大菠萝挂法,we... 透视插件!哈糖大菠萝挂法,wepoker透视脚本免费app,演示教程(都是是有挂)-哔哩哔哩1)we...
透视存在!hhpoker真能买... 透视存在!hhpoker真能买到挂吗,扑克之星辅助,模板教程(都是真的有挂)-哔哩哔哩hhpoker...
透视自建房!hhpoker可以... 透视自建房!hhpoker可以控制吗(透视)开挂辅助app(其实是真的挂)-哔哩哔哩该软件可以轻松地...
透视胜率!wepoker透视脚... 透视胜率!wepoker透视脚本免费下载pc(透视)开挂辅助方法(确实是有挂)-哔哩哔哩一、wepo...