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

相关内容

热门资讯

一分钟了解!红龙poker辅助... 一分钟了解!红龙poker辅助(辅助挂)确实是有挂(有挂方针)1、红龙poker辅助公共底牌简单,红...
技术分享!德普之星私人局辅助免... 技术分享!德普之星私人局辅助免费(辅助挂)切实是有挂(有挂神器)1、该软件可以轻松地帮助玩家将德普之...
一分钟教你!wepoker轻量... 一分钟教你!wepoker轻量版有透视吗(辅助挂)一贯是有挂(真的有挂)1、首先打开wepoker轻...
推荐一款!wepoker免费脚... 推荐一款!wepoker免费脚本咨询(辅助挂)本来有挂(今日头条)wepoker免费脚本咨询透视方法...
每日必备!wepokerplu... 每日必备!wepokerplus到底是挂了吗(辅助挂)好像真的有挂(有挂秘笈)1、游戏颠覆性的策略玩...
玩家必知教程!wpk有那种辅助... 玩家必知教程!wpk有那种辅助吗(辅助挂)本来存在有挂(有挂辅助)1、每一步都需要思考,不同水平的挑...
分享实测!wepoker网页版... 分享实测!wepoker网页版透视方法(辅助挂)都是真的有挂(有挂分析)1、wepoker网页版透视...
玩家实测!wpk插件辅助(辅助... 玩家实测!wpk插件辅助(辅助挂)总是是真的有挂(有挂技巧)1)wpk插件辅助有没有挂:进一步探索w...
查到实测!wepoker怎么看... 查到实测!wepoker怎么看牌型(辅助挂)真是是真的有挂(有挂总结)wepoker怎么看牌型脚本下...
一分钟教你!xpoker怎么作... 一分钟教你!xpoker怎么作弊(辅助挂)总是有挂(有挂方略)xpoker怎么作弊脚本下载中分为三种...