سؤال

I have an AJAX call that returns a list of places by name. I want these names to be strictly in English, but the API returns the name in the language of the request header's accept-language parameter. Some users have their browser's default language set to something other than English.

I am not familiar with this so I wanted to know if it is possible (in javascript or ruby) to alter the request header's accept-language parameter so that it is always English?

هل كانت مفيدة؟

المحلول

Yes it is possible.

xhr.setRequestHeader("Accept-Language", "en-US,fr-CA");

نصائح أخرى

xhr.setRequestHeader('Accept-Language','en-US')
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top