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买挂,切实有挂(有挂实锤)破解侠是真的助透视...
一分钟了解!wepoker透视... 一分钟了解!wepoker透视有用吗,pokerrrr2辅助,好像有挂(有挂方式)1、这是跨平台的轻...
一分钟秒懂!wepoker怎么... 一分钟秒懂!wepoker怎么设置透视,竞技联盟透视插件,真是是有挂(有挂方针)破解侠是真的助透视。...
一分钟了解!wepoker透视... 一分钟了解!wepoker透视脚本免费使用视频,werplan怎么作弊,真是真的有挂(有挂总结)1、...
必备科技!pokemmo辅助器... 必备科技!pokemmo辅助器脚本下载,大菠萝免费辅助,切实真的有挂(真的有挂)大菠萝免费辅助能透视...
最新技巧!大菠萝手游辅助,拱趴... 最新技巧!大菠萝手游辅助,拱趴大菠萝万能挂图解,其实是真的有挂(有挂技术)1、用户打开应用后不用登录...
最新技巧!wpk是真的还是假的... 最新技巧!wpk是真的还是假的,wepoker辅助软件价格,一直真的是有挂(有挂总结)1、进入游戏-...
玩家亲测!wepoker怎么拿... 玩家亲测!wepoker怎么拿到好牌,wepoker有用吗,其实真的有挂(有挂方式)1、很好的工具软...
一分钟了解!hhpoker德州... 一分钟了解!hhpoker德州有挂吗,德普之星透视免费,本来是真的有挂(有挂细节)1、操作简单,无需...
一分钟教会你!hhpoker辅... 一分钟教会你!hhpoker辅助软件是真的么,wpk辅助软件,果然真的是有挂(真实有挂)1、完成有辅...