JSFiddle - React, Tailwind, and code Playground

by masteram

HTML

<button id="form_results">bla</button>

JavaScript

$('f#orm_results').click(function () {
    var photo_annotations = {
        "12344": {
            "caption": "This is a caption for the photo ID 12344.",
                "keywords": "Keyword1, Keyword2, Keyword3",
                "credit": "John Doe",
                "credit_url": "http://www.johndoe.com"
        },
            "12345": {
            "caption": "This is a caption for the photo ID 12345.",
                "keywords": "Keyword4, Keyword5, Keyword6",
                "credit": "Joe Bloggs",
                "credit_url": "http://www.joebloggs.com"
        }
    };

    var the_obj = JSON.stringify(photo_annotations);
    var data_str = "annotations=" + the_obj;
    $.ajax({
        type: 'POST',
        dataType: 'html',
        url: 'http://j31/index.php',
        data: data_str,
        success: function (data) {
            if (data) {
                $('#form_results').html(data);
            } else {
                console.log("No data");
            }
        },
        error: function () {
            console.log("Request error");
        }
    });
});