I am a beginner in Ajax. I want to fetch data row from Subject Table consist of only one column Subject as varchar(100), defined in MySQL DB. Following is my php code.
Data.php
<?php
$con=mysqli_connect("","root","root","DBTemp") or die("</br> Error: " .mysqli_connect_error());
$sql="select * from Subject";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_assoc($result))
{
echo $row["SUBJECT"];
//I Want This Value to Be received in my Jquery Page
//So that i can take certain action based on each Subject.
//For example creating a select box child elements,options.
}
?>
Jquery.js
$(document).ready(function()
{
var response='';
$("body").ready(function()
{
$.ajax(
{
url: '/Data.php',
type: 'GET'
success: function(text)
{
response=text;
}
});
});
$("body").append("<select> /*Get values here as options*/ </select>");
});
But The Desired action is getting values row by row like:- 1st row value comes-> take certain action in jquery; 2nd row value comes-> take sertain action..; . . so on.