I have been trying to post the form contents from inside of my windows 8.1 app to a php file on the server. However, I am keep getting an Access denied error:
Exception is about to be caught by JavaScript library code at line 4143, column 21 in ms-appx://microsoft.winjs.2.0/js/base.js
0x80070005 - JavaScript runtime error: Access is denied.
If there is a handler for this exception, the program may be safely continued.
Below is my code:
$("#register_button").click(function (event) {
event.preventDefault();
var url = $("#registration_form").attr("action");
var type = "POST";
var username = $("#username").val();
var password = $("#password").val();
var email = $("#email").val();
var firstName = $("#first_name").val();
var lastName = $("#last_name").val();
var data = "username=" + username + "&password=" + password + "&email=" + email + "&first_name=" + firstName + "&last_name=" + lastName;
console.log(data);
WinJS.xhr({
url: url,
type: type,
data: data,
headers: { "Content-type": "application/x-www-form-urlencoded" }
})
.then(function (success) {
console.log(success.statusText);
}, function (error) {
console.log(error);
alert(error.message);
});
});
}));
Please tell me how to rectify this error, and if its there a better way or the correct way to do it. Just guide me how to do this. Thanks :)
The "alert" function is not authorised on HTML/Javascript Windows 8/8.1 apps