I have a problem on my codes that uses jquery ajax to execute the php script and returns the data back to the browser. I want to return more one value from the 'echo' output of my php script. So I use json_encode to return the data inform of arrays. But my codes here does not return any value and no responses happening in my browser. Here is my codes.
// AJAX Code To Submit Form
// Get the value from selectbox
var so = $(this).find('option:selected').text();
var dataString = 'so1='+ so;
$.ajax({
type: "POST",
url: "functions/ajaxsubmit.php",
data: dataString,
cache: false,
success: function(response){
var pos1_text = $("#pos1").text(response.a);
}
});
and heres my php code ajaxsubmit.php
<?php
include("connection.php");
//Fetching Values from URL
$sign1 = $_POST['so1'];
//Display Signing Position
$sql = "SELECT * FROM signing_officer WHERE signing_incharge = '$sign1'";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$dbSigning_id = $row['signing_id'];
$dbSigning_position = $row['signing_position'];
}
$output = array('a' => $dbSigning_id, 'b' => $dbSigning_position);
echo json_encode($output, JSON_FORCE_OBJECT);
?>
Can anyone help me find the bug with this code? Really needed this.. Thankyou
JSON.parse()