I'm doing a cross domain request for IE using the XDomainRequest in this way:
<div id="result"></div>
<script type="text/javascript">
var urlToOpen;
var openxUrl = "http://DOMAIN.com/www/delivery/apu.php";
if ($j.browser.msie && window.XDomainRequest) {
// Use Microsoft XDR
var xdr = new XDomainRequest();
xdr.open("get", openxUrl);
xdr.onload = function() {
urlToOpen = xdr.responseText;
};
xdr.send();
}
$j('#result').html(urlToOpen)
</script>
The code return the correct value, but I want to use the value of the Ajax return in other functions (not only inside the function of xdr.onload), so I need that what is returned with xdr.responseText can be declared as global or something like that.
Example: The last line $j('#result').html(urlToOpen) pretend to assign the value of "urlToOpen" but this does not work. How can I achieve this ?