Set Accept headers in jQuery to retrieve data in iframe
I have a webpage to which I add an iframe as follows:
$('<iframe id="testIframe" />').src('http://www.google.nl/').appendTo('body');
The following values are set in the Accept headers sent to download the contents of this iframe:
application/xml, application/xml+xhtml, text/html, text/plain, */*
The problem is that the response is now returned as XML, because accept headers are read on the server side, and the response is sent back in the format sent by the accept header (in this case, the / xml application is used).
Now I know that I can use the $ .load () function and set acceptance headers for this, but I don’t know how to show the returned HTML in an iframe. For example, this shows an empty iframe:
$('#testIframe').load('http://www.google.com/', function(response) {
$('#testIframe').append(response);
});
Any help would be greatly appreciated!