0

This is my my code which calls AJAX function:

$result = ajax_submitter("POST", "/documents/merge_documents", {doc_id_list: $doc_id_array});

function ajax_submitter($type, $url, $data_submit)
{
    $result = $.ajax({
        url: $url,
        type: $type,
        data: $data_submit,
        dataType: "JSON",
        cache: false,
        timeout: 0,
        error: function (jqXHR, textStatus, errorThrown) {
            console.log("Error:\n" + errorThrown + '\n' + textStatus);
        },
        success: function (return_data, status) {
        }
    });
    return $result;
}

This AJAX function calls a PHP method which returns this:

echo json_encode(array('text' => 'This function is not implemented yet'));

And this is what I see in Chrome's console: enter image description here

NOW my question is how do I access 'responseJSON' or 'responseText', and is this output a JSON object, if not then what type of object is it?

Keyur Padalia
  • 2,077
  • 3
  • 28
  • 55
  • look at your success function, you can console.log the return_data parameter, should be something like `console.log(return_data.d)` – Stavm May 18 '17 at 12:14
  • return_data.responseJSON or return_data.responseJSON.responseText – hjm May 18 '17 at 12:15

0 Answers0