开发者

Send a simple GET request

I want to send a server simp开发者_如何学Pythonle 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)
                        })
                    }, 
                    })

in headers ---> X-Requested-With: XMLHttpRequest

Is it possible to send a simple request without using x-request-with?


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) {....

or

                         beforeSend: function(xhr) {
                                xhr.setRequestHeader("Content-type", 
                         "application/json; charset=utf-8");
                         },

Encosia has a good post about this from the .net enviroment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜