IE8 及 360 ajax window.open
發表於 : 2016-10-10 17:51:28
代碼: 選擇全部
<!DOCTYPE html>
<html>
<head>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- IE9 以下的 cross site ajax -->
<!--[if lte IE 9]>
<script type="text/javascript" src="jquery.xdomainrequest.min.js"></script>
<![endif]-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<style>
#myButton {
border: red outset 4px;
display: inline-block;
background-color: gray;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<div id="myButton">Click Me</div>
<script>
$('#myButton').click(function() {
$.ajax({
url: 'echo_json.php',
type: 'post',
datatype: 'json',
async: false,
data: {"ids" : ""},
success: function(data) {
//console.log(data);
if(true){
window.open(data.URL,'_blank');
}else{
alert('Error');
}
}
});
});
</script>
代碼: 選擇全部
<?php
$arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5,
'url' => 'http://www.551.com.tw',
'URL' => 'http://www.551.com.tw',
);
//$arr = array();
header('Content-Type: application/json');
//echo "{}";
echo json_encode($arr);