如何使用类型:“POST"在 jsonp ajax 调用中 [英] How to use type: "POST" in jsonp ajax call
问题描述
我正在使用 JQuery ajax jsonp.我有以下 JQuery 代码:
I am using JQuery ajax jsonp. I have got below JQuery Code:
$.ajax({
type:"GET",
url: "Login.aspx", // Send the login info to this page
data: str,
dataType: "jsonp",
timeout: 200000,
jsonp:"skywardDetails",
success: function(result)
{
// Show 'Submit' Button
$('#loginButton').show();
// Hide Gif Spinning Rotator
$('#ajaxloading').hide();
}
});
上面的代码工作正常,我只想将请求发送为 "POST" 而不是 "GET",请建议我如何实现这一点.
The above code is working fine, I just want to send the request as "POST" instead of "GET", Please suggest how can I achieve this.
谢谢
推荐答案
您不能使用 JSONP 进行 POST...它根本不能那样工作,它创建了一个 获取数据的元素...必须是一个 GET 请求.除了发布到您自己的域作为代理发布到另一个域之外,您无能为力……但是用户将无法直接执行此操作并查看回复.
You can't POST using JSONP...it simply doesn't work that way, it creates a <script>
element to fetch data...which has to be a GET request. There's not much you can do besides posting to your own domain as a proxy which posts to the other...but user's not going to be able to do this directly and see a response though.
这篇关于如何使用类型:“POST"在 jsonp ajax 调用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!