发送一个简单的GET请求 [英] Send a simple GET request
本文介绍了发送一个简单的GET请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想送一台服务器简单的GET请求,但我看到了阿贾克斯发出的X要求,与标头,我的服务器不理解。
I want to send a server simple GET request but as I see the .ajax sends x-requested-with header which my server doesn't understand.
$.ajax({
type: 'GET',
url: 'coord-' + x + '-' + y + '-' + iname,
success: function(data) {
$('img').each(function(idx, item) {
var img_attr = $(this).attr("src")
var name = img_attr.match(/\d+-\d+\.\w+/)
name = name + '?r=' + Math.random()
$(this).removeAttr("src")
$(this).attr("src",name)
})
},
})
在头---> X-要求,通过:XMLHtt prequest
是否有可能发出一个简单的请求,而无需使用的X请求呢?
in headers ---> X-Requested-With: XMLHttpRequest
Is it possible to send a simple request without using x-request-with?
推荐答案
这看起来像你需要设置的contentType参数,是这样的:
This looks like you need to set the contentType parameter, something like this:
$.ajax({
type: 'GET',
url: 'coord-' + x + '-' + y + '-' + iname,
contentType: 'application/json; charset=utf-8'
success: function(data) {....
或
beforeSend: function(xhr) {
xhr.setRequestHeader("Content-type",
"application/json; charset=utf-8");
},
Encosia 已经从.NET环境这个好岗。
Encosia has a good post about this from the .net enviroment.
这篇关于发送一个简单的GET请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文