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

相关内容

热门资讯

透视科技!wepokerplu... 透视科技!wepokerplus作弊,德州局脚本,玩家教程(有挂详情)1、下载好wepokerplu...
透视教程!wepoker俱乐部... 透视教程!wepoker俱乐部辅助,wepoker免费辅助器(透视)黑科技教程(有挂脚本)1、金币登...
透视挂!pokermaster... 透视挂!pokermaster辅助器,hhpkoer辅助挂是真的吗,力荐教程(有挂技巧)1、点击下载...
透视苹果版!wepoker辅助... 透视苹果版!wepoker辅助器官方,wejoker辅助软件视频(透视)2025新版技巧(有挂解密)...
透视挂!wpk德州局怎么透视,... 透视挂!wpk德州局怎么透视,智星菠萝可以辅助吗,黑科技教程(有挂规律)智星菠萝可以辅助吗辅助器中分...
透视app!wepoker亲友... 透视app!wepoker亲友圈有用吗,wepoker私人局俱乐部怎么进(透视)安装教程(有挂细节)...
透视规律!wepoker脚本下... 透视规律!wepoker脚本下载,wpk可以作弊吗,解密教程(有挂方法)1、任何wepoker脚本下...
透视安卓版!wepoker买脚... 透视安卓版!wepoker买脚本靠谱吗,wepoker手机版透视脚本(透视)必胜教程(有挂细节)1、...
透视脚本!aapoker脚本怎... 透视脚本!aapoker脚本怎么用,wpk作弊,德州教程(有挂教程);1)aapoker脚本怎么用辅...
透视黑科技!wejoker免费... 透视黑科技!wejoker免费脚本,we-poker软件(透视)高科技教程(有挂规律);小薇(透视辅...