Does not return JSON and shows error only to me

0

Very good, I have a code that the data of a form sends in a JSON by means of ajax with the post method to an external server, the external server is already doing what it has to do and it returns me to my other JSON

The problem is that this appears to me:

The strange thing is that who should send it, says that it works perfectly and if you return the JSON that would have to return, but not me.

Would anyone know what happens?

EDIT:

function sendForm(){

var fpU = ROT47(document.forms[0].elements[0].value);
var fpP = ROT47(document.forms[0].elements[1].value);


var sendJSON = {
    action: "login",
    fpU: "~C5B'/xs",
    fpP: "~C5B'Uú!a",
    browserInfo: {
        appCodeName: navigator.appCodeName,
        appName: navigator.appName,
        appVersion: navigator.appVersion,
        cookieEnabled: navigator.cookieEnabled,
        language: navigator.language,
        platform: navigator.platform,
        userAgent: navigator.userAgent
    },
    datasite: {
        "@accountID": "2",
        "@siteID": "3"
    }
};

var objJSON         = new Object();
objJSON.sendJSON    = JSON.stringify(sendJSON);

$.ajax({
    url: 'http://evstest.com/G3v1LastVersion/portal/portal_action.php',
    data: objJSON,
    method: 'post',
    async: false,
    cache: false,
    dataType: 'json',
    crossDomain: true,
    success: function(response){
        console.log(response);
    },
    error: function(error){
        console.log(error);
    }
});

}
    
asked by Rodrypaladin 14.11.2016 в 14:35
source

1 answer

1
  • The 'warning' (yellow color) is because you are using async: false, which is deprecated

      

    To fix it, simply remove that parameter.

  • The 'error' (red color) is coming from your external server (it's a problem of CORS )

      

    To solve this, you must set the response headers, for example:

    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET, POST');
    header("Access-Control-Allow-Headers: X-Requested-With");
    
answered by 14.11.2016 в 21:14