Angularjs 错误http.get

Angularjs 错误http.get,angularjs,http,Angularjs,Http,我有一个让我发疯的问题。这是一款带有Ionic/angular的移动应用程序,需要您的帮助: 在我的代码中,我对get数组发出http请求,如下所示: {"Exist": 0} 我确信发出此请求的服务器已运行并接收该请求,因为在记录器中我看到了该请求 我已经写了一些日志消息,以查看我的应用程序在哪里出错,并始终停止.error部分 js angular.module('starter.controllers', []) .factory('validaEmail', function($ht

我有一个让我发疯的问题。这是一款带有Ionic/angular的移动应用程序,需要您的帮助:

在我的代码中,我对get数组发出http请求,如下所示:

{"Exist": 0}
我确信发出此请求的服务器已运行并接收该请求,因为在记录器中我看到了该请求

我已经写了一些日志消息,以查看我的应用程序在哪里出错,并始终停止.error部分

js

angular.module('starter.controllers', [])

.factory('validaEmail', function($http) {

    return {
        existeEmail: function($correo){
            console.log("Dentro de validaEmail");
            $http.get("http://www.promozzapp.com/php/validaUser.php?email=" +$correo)
                .success(function(valor1, valor2) {
                    console.log("SUCESS ");
                    window.alert("SUCESS");

                })
                .error(function (data, status, headers, config){
                    console.log("ERROR - "+data+" - "+status);
                    window.alert("ERRORR" + data +  " - "  +status + " - H: " +headers);

                })
                .then(function(response) {
                    console.log("**** THEN **** " );
                });
        }   
    };
})
<html>
  <head> 
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' http://www.promozzapp.com  'unsafe-eval' 'unsafe-inline';">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
index.html

angular.module('starter.controllers', [])

.factory('validaEmail', function($http) {

    return {
        existeEmail: function($correo){
            console.log("Dentro de validaEmail");
            $http.get("http://www.promozzapp.com/php/validaUser.php?email=" +$correo)
                .success(function(valor1, valor2) {
                    console.log("SUCESS ");
                    window.alert("SUCESS");

                })
                .error(function (data, status, headers, config){
                    console.log("ERROR - "+data+" - "+status);
                    window.alert("ERRORR" + data +  " - "  +status + " - H: " +headers);

                })
                .then(function(response) {
                    console.log("**** THEN **** " );
                });
        }   
    };
})
<html>
  <head> 
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <meta http-equiv="Content-Security-Policy" content="default-src 'self' http://www.promozzapp.com  'unsafe-eval' 'unsafe-inline';">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

首先,尝试在浏览器中输入此url:

您将看到,它返回无效的JSON字符串

其次,这个url返回
text/html
响应,而不是
json


您的错误存在于
validaUser.php
文件中的后端代码中

您的
success
回调代码是否被调用?在
success
error
回调中都放置
debugger
关键字,并验证它错误消息是什么?(在提供给
错误
回调的错误中)这似乎与您的JSON有关。选中此项:,使用另一个JSON它可以正常工作。尝试将
validaUser.php
的标题设置为JSON类型