• 0

Windows Phone 7/IE9 jQuery ajax


Question

I'm trying to use the following code with jQuery on Windows Phone 7.5. Every time I try to make a ajax request for xml I get returned "Access is Denied" from the error handler. JSONP is not going to work in this scenario, unfortunately as the data I need is only in XML. I'm not sure how I'd go about fixing this issue. I should point out, that the code works fine on Chrome and Safari, but fails on Windows Phone 7.5 and IE9.

Javascript:


function loadData(index) {
$.support.cors = true;
$.mobile.allowCrossDomainPages = true;
$.ajax({
url: "http://foo.bar/some.php",
dataType: "xml",
success: parseData,
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("Status: " + textStatus); alert("Error: " + errorThrown);
}
});
};
[/CODE]

[/font][/color]

PHP Proxy to fetch XML from server that doesn't support cross site.

[CODE]
<?php
header('Content-type: text/xml');
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
$intme = date('YmdHis');
$start = $_GET['ind'];
$url = "http://some.data.source/data.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
[/CODE]

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

This topic is now closed to further replies.