I am trying to use localization in javascript where localization strings are stored in a php file and get\_string() function is used to get the localized values in php. I've written a script called alertpopup.php

```
$alertmessage = $_POST['msg'];

switch($alertmessage)
{
    case '1':
        $alertmessage = get_string('first');
        break;
    case '2':
        $alertmessage = get_string('second');
        break;
    case 'deletecomment':
        $alertmessage = get_string('random');
        break;  
}

echo json_encode(Array('Message' => $alertmessage));

```

and a script in javascript to get value from this php script:-

```
            var answer;
        $.ajax( {
        type: "POST",
        data: "msg=1",
        url: "alertpopup.php",
        success: function(data) {
        var alertmsg = $.parseJSON(data);

            if (alertmsg.Message != null) {
                answer = confirm(alertmsg.Message);
                document.location.reload();
            }

        }
       });
        if(answer) {
                     something
                }
                else{
                    something else
                }

```

However, I keep getting error:-
Uncaught TypeError: Object function (E,F){return new o.fn.init(E,F)} has no method 'parseJSON' 

Can someone help me with the issue?