I made an app with Phonegap Cordova and when I test it on Android everything is OK, but when I test it on Windows Phone 8.1 it gives me the following error:
APPHOST9601: Can't load http://www.example.com/apiv2/process.php/Login2?Email=xxxx@xxxx.com&Password=7c4a8d09ca3762af61e59520943dc26494f8941b&callback=angular.callbacks._0 . An app can't load remote web content in the local context. File: index.html. I am using Angularjs and Onsenui.
EDITED:
The code is:
var apiprincipal = 'http://www.example.com/apiv2/process.php/';
// Log In Controller
app.controller('loginController', [ '$http', '$scope', '$rootScope', function($http, $scope, $rootScope){
$scope.email = '';
$scope.password = '';
$scope.loginN = function(){
if($scope.email==='' && $scope.password===''){
ons.notification.alert({message: "Vo\u00E7\u00EA dever\u00E1 preencer os dois campos usu\u00E1rio e senha"});
} else {
modal.show();
$http.jsonp(apiprincipal+'Login2?Email='+$scope.email+'&Password='+CryptoJS.SHA1($scope.password)+'&callback=JSON_CALLBACK').success(
function(response){
if(response.status=='ok'){
console.log('WORKING')
} else{
modal.hide();
}
}
);
}
};
}]);
First, try removing some unnecessary code for a more readable question.
Your URL should look like this
$http.jsonp(apiprincipal+'Login2?Email='+$scope.email+'&Password='+CryptoJS.SHA1($scope.password)+'&_jsonp=JSON_CALLBACK')
in case that &_jsonp=JSON_CALLBACK
doesn't work, change it for ?_jsonp=JSON_CALLBACK
I was with the same in my app and yesterday I was reading an article, so I fix it like this:
http://amyurl.com/wp-json/posts?_jsonp=JSON_CALLBACK
now it is working.
I had the same issue when targeting Windows 8.1.
First I checked my backend supported CORS. I didn't find a way to keep JSONP in Windows 8.1, I had to change it into a simple GET method. Then I removed 'callback' from the URL.
Referring to your code, it should look like that
$http.get(apiprincipal+'Login2?Email='+$scope.email+'&Password='+CryptoJS.SHA1($scope.password)).success(function(response) {
if(response.status=='ok'){
console.log('WORKING');
} else{
modal.hide();
}
});
It worked fine for me, hope it can help someone else.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.