1

The response of success ajax call is in the form of json like this one:

{"prize_name":"Keys 4","prize_image":"http:\/\/localhost\/web-game-w\/wp-content\/uploads\/2017\/09\/4rare.jpg"}

How I can store "prize_name" & "prize_image" in variables for later use?

Here is the ajax code:

$("#ajax").click(function(e){
    e.preventDefault();
    var data = {
        'action': 'getprize_data',
        dataType: "json", 
        async: false
    };
    $.post(ajaxurl, data, function(response) {
        console.log(response);
        // Store vars 
    });
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.