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

相关内容

热门资讯

发现一款!aapoker辅助挂... 发现一款!aapoker辅助挂多功能透视工具,本来是真的有挂(有挂细节)aapoker能透视中分为三...
技术分享!wepoker辅助挂... 技术分享!wepoker辅助挂多功能透视工具,确实是有挂(有挂技术)亲,关键说明,wepoker透视...
重磅来袭!微扑克辅助挂多功能透... 重磅来袭!微扑克辅助挂多功能透视工具,其实有挂(有挂工具)1、操作简单,无需微扑克手机版透视脚本,只...
总算明白!WPK辅助挂多功能透... 总算明白!WPK辅助挂多功能透视工具,确实是真的有挂(有挂秘诀)1)WPK有没有挂:进一步探索WPK...
带你了解!德扑圈辅助挂多功能透... 带你了解!德扑圈辅助挂多功能透视工具,真是存在有挂(真是有挂)德扑圈脚本下载中分为三种模型:德扑圈挂...
一分钟快速了解!wpk辅助挂多... 一分钟快速了解!wpk辅助挂多功能透视工具,原来真的是有挂(有挂教学)1、许多玩家不知道wpk辅助怎...
实测教程!AAPoKer辅助挂... 实测教程!AAPoKer辅助挂多功能透视工具,果然是真的有挂(有挂细节);1、进入游戏-大厅左侧-新...
研究成果!德扑之星辅助挂多功能... 研究成果!德扑之星辅助挂多功能透视工具,原来存在有挂(有挂方略)德扑之星破解侠是真的助透视。每个模型...
必知教程!微扑克辅助挂多功能透... 必知教程!微扑克辅助挂多功能透视工具,其实真的是有挂(有挂猫腻)1、实时微扑克透视辅助更新:用户可以...
玩家必备教程!德扑之星辅助挂多... 玩家必备教程!德扑之星辅助挂多功能透视工具,一直真的是有挂(有挂解密)德扑之星辅助器是一种具有地方特...