Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Javascript error: SyntaxError: Unexpected token < in JSON at position 2
maxerxxl
post
Post #1





Grupa: Zarejestrowani
Postów: 19
Pomógł: 0
Dołączył: 29.03.2014

Ostrzeżenie: (0%)
-----


Cześć.

Mam pewien problem otóż co chwile pojawia mi się błąd i nie wiem jak go naprawić.

Kod
exit(
    json_encode(array('success' => false, 'error' => 'You must login to access the redeem.'))
);


Kod
function redeem(){
    var code = $("#promo_code").val();
    $.ajax({
        url:"/pages/config/promo_code.php?code="+code,

        success:function(data)
        {
            try
            {
                data = JSON.parse(data);
                console.log(data);

                if (data.success)
                {
                    bootbox.alert("Success! You've received "+data.credits+" credits.");                    
                }

                else
                {
                    bootbox.alert(data.error);
                }
            }

            catch (error)
            {
                bootbox.alert("Javascript error: "+error);
            }
        },

        error:function(error)
        {
            bootbox.alert("AJAX error: "+error);
        }
    });
}
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 15:31