我大多剪切并粘贴了这个:
当我通过浏览器向其传递网址时,该应用运行良好。
但是当我尝试通过jquery通过ajax调用获取数据时(即使启用了JSONp)我仍然收到错误。
$.ajax({
url: 'https://NOTTHEACTUALADRESS.com&callback=?',
type: 'GET',
dataType: 'jsonp',
timeout: 3000,
success: function(result) {
alert ("success");
},
error: function(result) {
alert (result.status);
}
});
我在Azure上遗漏了什么?
请帮忙!
答案 0 :(得分:0)
让它发挥作用!
(1)在azure上激活CORS:https://docs.microsoft.com/en-us/azure/app-service-api/app-service-api-cors-consume-javascript
(2)在我的index.html中更改了:
<body>
<?php
//To start, there is a form with a dropbox and a button, which will have the various functions that can happe
?>
<form action="search_start.php" method="post">
<!-- here -->
<?php
$fns_to_choose = array("Option 1" =>"Get A Monthly Report","Option 2" => "Track One Ship Over Time", "Option 3" => "Track Multiple Ships Over Time", "Option 4" => "Get Ships Over Time For One") // here
?>
<select name="Functions"> <!-- here -->
<?php
foreach ($fns_to_choose as $key => $value)
{
echo '<option value="' . $key . '">' . $value . '</option>';
}
?>
</select>
</form>
</body>
TO
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">
OMG我在整个过程中付出了这一天!