Does Ajax not work in a XAML WebView? Whenever I make an Ajax call it always runs the error callback.
Just for your reference here is the test.js code:
$(function () {
$.ajax({
url: "http://fake_domain_here/api/v1/api_call", //I use a real domain name...I just removed it here.
data: {
id: 1
},
type: "GET",
datatype: "json",
timeout: 30000,
success: function (data, textStatus, xhr {
window.external.notify("HERE 1");
},
error: function (xhr) {
window.external.notify("HERE 2"); //always goes here.}
});
});
test.html file:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="js/test.js"></script> </head>
<body>
<h1>In here.</h1>
</body>
</html>
In the XAML file I do this
<Page
x:Class="APPNAMECLASSHERE"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:LSWApp"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<WebView x:Name="wv" HorizontalAlignment="Left" Height="748" VerticalAlignment="Top" Width="1346" Margin="10,10,0,0" ScriptNotify="script_notify"
Source="ms-appx-web:///Assets/www/test.html"/>
</Grid>
</Page>
What do you guys suggest I try to see if that fixes the ajax issue?
Thanks.