views:

56

answers:

2

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

in headers ---> X-Requested-With: XMLHttpRequest
Is it possible to send a simple request without using x-request-with?

A: 

Yes, it is possible.

no
_no_, could you please tell how?
Qwerto
A: 

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.

Steve Mc