Reputation: 1769
I'm building a chrome extension in javascript.
I'm trying to get the page contents from an Outlook mailserver through an ajax request, but I have trouble getting the correct page returned.
I suspect it is the danish letter æ, that creates the problem, but don't know how to resolve it.
$.ajax({
url: baseURL + 'Indbakke/',
data: "Cmd=contents&View=Ulæste%20meddelelser", //Avoid encodeURI
dataType: 'html',
processData: false, //Avoid encodeURI
cache: false,
success: function(data) {
fetchedInbox = $.parseHTML(data);
//If there are changes to the inbox, refresh the inbox page
if(findString(fetchedInbox, 'ingen emner'))
{
window.parent.frames[1].location = baseURL + 'Indbakke/?Cmd=contents';
}
},
complete : function(){
console.log("URL" + this.url)
}
});
The data variable of the succes function contains the wrong page, but if I copy 'this.url' from the complete function into a browser, it displays the right page. I have tried using default ajax settings and encodeURI on the full link (without using the 'data' option), but then neither 'data' or 'this.url' will work (i.e. I change the second parameter to 'View=Ul%C6ste%20meddelelser').
I do not have access to the (probably) asp page that the server sends, just javascript, so I can't do anything serverside.
Note: When chromes console show this.url, it breaks the link before æ, so I have to manually copy the url
Upvotes: 1
Views: 611
Reputation: 2949
It's probably the æ
that creates this error. Replace æ
by %C3%A6
and the headers will be send to the correct location.
data: "Cmd=contents&View=Ul%C3%A6ste%20meddelelser"
To find the encoded character, I used this converter: http://meyerweb.com/eric/tools/dencoder/
Upvotes: 1