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模拟器哪个,hhpoker德州透视挂,确实真的是有挂(有挂分析)1、透视辅助...
热点推荐!wepoker辅助是... 您好,wepoker辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多...
今日头条!wejoker辅助软... 今日头条!wejoker辅助软件价格,wepoker辅助器,果然真的有挂(有挂细节)1、wepoke...
程序员教你!wepoker手机... 程序员教你!wepoker手机版辅助,hh poker辅助有用吗,都是是真的有挂(有挂神器)1、进入...
热点推荐!wepoker有用吗... 热点推荐!wepoker有用吗,wpk作弊最怕三个东西,本来真的是有挂(有挂攻略)1、下载好脚本下载...
科普!we-poker正规吗,... 科普!we-poker正规吗,pokernow辅助控制,原来存在有挂(有挂头条)1、下载好正确养号方...
科普常识!wepoker透视脚... 科普常识!wepoker透视脚本免费使用视频,werplan怎么作弊,竟然存在有挂(有挂秘笈)1、完...
一分钟揭秘!云扑克有透视吗,p... 一分钟揭秘!云扑克有透视吗,pokemmo脚本,原来真的有挂(有挂教学)能透视中分为三种模型:模拟器...
热点推荐!xpoker辅助控制... 热点推荐!xpoker辅助控制,哈糖大菠萝有挂吗,确实有挂(讲解有挂)该软件可以轻松地帮助玩家将外卦...
最新通报!德州局透视脚本,we... 最新通报!德州局透视脚本,wepoker怎么挂底牌,其实是有挂(讲解有挂)1、玩家可以在透视最简单三...