Javascript + Ajax is not returning as expected


I'm trying to send this page's data to the server, but Js doesn't return the Message variable…


I know little about JS and would like to know how to call the variable as soon as the server receives the data.


Enable server-side CORS… ( )

If you add an error to your ajax, you'll notice it lands there.

    type: "GET",
    url:  strUrl,
    crossDomain: true,
    dataType: 'jsonp',
    beforeSend: function (xhr) {
       xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
    success: function(data)
        if (data == "Realizado com sucesso.")
            var Mensagem = "Obrigado por se cadastrar na BILLABONG!";

            $("#divNewsLetterContainer").append("<span class='spnMensagemNewletter'>" + Mensagem + "</span>");
    error: function(data) {
        alert('Ocorreu um erro, olhe o console');

Add an action to your form:

   <form action="javascript:void(0);" id="divNewsLetterContainer" class="newsletter" onsubmit="EnviarNewsLetter();">
        <input type="text" class="fitext" name="nome" id="nome" size="20" value="" placeholder="name" required="">
        <input type="email" name="email" id="email" size="20" value="" placeholder="" required="">
        <input type="submit" id="btw-ok" value="assinar" class="btw-ok">
Scroll to Top