I have an ajax request which gets a json string but for some reason it has started returning "undefined", The json string does return valid JSON but its just not working!
Ajax request:
if (editSeq) {
$.ajax({
url: './json/admin/getData.php',
type: 'POST',
async: false,
data: { SEQ: editSeq },
dataType: 'json',
success: function (data) {
var HTML = data.HTML;
$('#blankform').append(HTML);
alert(HTML);
}
});
JSON:
<?php
include("../../includes/db.php");
$SEQ = $_POST["SEQ"];
$sth = sqlsrv_query($conn,"SELECT HTML from TBL_DATA WHERE Sequence = " . $SEQ);
$rows = array();
while($r = sqlsrv_fetch_array($sth,SQLSRV_FETCH_ASSOC)) {
$rows[] = $r;
}
if( $sth === false)
{
echo "Error in query preparation/execution.\n";
die( print_r( sqlsrv_errors(), true));
}
print json_encode($rows);
?>
This is my JSON response:
[
{
"HTML": " \n\n<div id=\"div_143\" style=\"width: 300px; white-space: nowrap; padding-right: 50px; left: 60px; top: 48px;\" class=\"ui-resizable ui-draggable ui-resizable-disabled ui-state-disabled\" aria-disabled=\"true\"><label> Incident # <input type=\"text\" style=\"width:100%;\" id=\"input_143\" role=\"textbox\" aria-autocomplete=\"both\" aria-disabled=\"false\" aria-readonly=\"false\" aria-multiline=\"false\" class=\"jqx-widget-content jqx-widget-content-web jqx-input jqx-input-web jqx-widget jqx-widget-web jqx-rc-all jqx-rc-all-web\" placeholder=\"\" disabled=\"disabled\"><\\/label><div class=\"ui-resizable-handle ui-resizable-e\" style=\"z-index: 90;\"><\\/div><div class=\"ui-resizable-handle ui-resizable-w\" style=\"z-index: 90;\"><\\/div><div class=\"ui-resizable-handle ui-resizable-sw\" style=\"z-index: 90;\"><\\/div><div class=\"ui-resizable-handle ui-resizable-ne\" style=\"z-index: 90;\"><\\/div><div class=\"ui-resizable-handle ui-resizable-nw\" style=\"z-index: 90;\"><\\/div><div class=\"ui-resizable-handle ui-resizable-se ui-icon ui-icon-gripsmall-diagonal-se\" style=\"z-index: 90;\"><\\/div><\\/div>"
}
]