I am attempting to query a SQL Server Database and return the results onscreen. My page loads as it should, but when I push the button to query SQL Server if I look at the console it shows a 500 error.
What do I need to alter so that the valid results are returned on screen as I need?
<select name="peopleinfo[]" multiple style="min-width: 200px;" id="peopleinfo">
<option value="red">Red</option>
<option value="blue">Blue</option>
</select>
<div><input type="submit" value="Submit" id="ajaxButton" onclick="ReturnIt()"></div>
<div id="result_data"></div>
<script>
function ReturnIt(){
var peopleinfo = $('#peopleinfo').val();
jQuery.ajax({
url: "",
type: 'POST',
dataType: "html",
data: { peopleinfo: peopleinfo },
success : function(result) {
$('#result_data').empty();
$('#result_data').append(result);
} ,
error: function(){
}
});
}
</script>
$peopleinfo = implode(',',$_REQUEST['peopleinfo']);
$option = array(); //prevent problems
$option['driver'] = 'mssql'; // Database driver name
$option['host'] = 'Lockwood'; // Database host name
$option['user'] = 'root'; // User for database authentication
$option['password'] = 'sa'; // Password for database authentication
$option['database'] = 'test'; // Database name
$option['prefix'] = ''; // Database prefix (may be empty)
$db = JDatabase::getInstance( $option );
$result = $db->getQuery(true);
$result->select($db->quoteName(array(".$peopleinfo.")));
$result->from($db->quoteName('[redheadstepchild]'));
$db->setQuery($result);
$row = $db->loadRowList();
print_r($row);
EDIT
This is what the dev console shows
an error on this line jquery-1.12.4.js:10254
And this is the actual syntax when I click that
// Do send the request
// This may raise an exception which is actually
// handled in jQuery.ajax (so no try/catch here)
xhr.send( ( options.hasContent && options.data ) || null );