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

相关内容

热门资讯

两分钟辅助!哈糖大菠萝挂,德普... 两分钟辅助!哈糖大菠萝挂,德普之星辅助工具如何打开,资料教程(有挂教程)1、两分钟辅助!哈糖大菠萝挂...
三分钟辅助!hhpoker辅助... 三分钟辅助!hhpoker辅助靠谱吗,hh poker透视器下载,窍要教程(详细教程)所有人都在同一...
第九分钟辅助!德普之星透视,w... 第九分钟辅助!德普之星透视,wpk透视辅助方法,指引教程(有挂秘诀)进入游戏-大厅左侧-新手福利-激...
6分钟辅助!拱趴大菠萝机器人,... 6分钟辅助!拱趴大菠萝机器人,wepoker养号规律,绝活儿教程(有挂头条)1、拱趴大菠萝机器人有没...
第4分钟辅助!wepoker透... 第4分钟辅助!wepoker透视方法,德州私人局脚本,举措教程(有挂头条)德州私人局脚本能透视中分为...
9分钟辅助!德普之星私人局辅助... 9分钟辅助!德普之星私人局辅助器,xpoker辅助神器,机巧教程(证实有挂)进入游戏-大厅左侧-新手...
第3分钟辅助!we poker... 第3分钟辅助!we poker辅助器v3.3,wepoker透视功能下载,机巧教程(有挂透视)1、超...
第8分钟辅助!wepoker怎... 第8分钟辅助!wepoker怎么开辅助,黑侠破解wepoker,课程教程(今日头条)1、上手简单,内...
第十分钟辅助!如何下载wpk透... 第十分钟辅助!如何下载wpk透视版,pokerworld软件,策略教程(有挂分享)如何下载wpk透视...
九分钟辅助!wepoker辅助... 九分钟辅助!wepoker辅助真的假的,cloudpoker作弊,手筋教程(证实有挂)1、每一步都需...