4

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?

2
  • 1
    Your server should ignore any request it does not understand. Do you get an error message? Commented Jul 8, 2010 at 15:46
  • the server ignores it already, i can't even see the request in log. Commented Jul 8, 2010 at 16:15

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.