how to fetch data using jquery
- by user3566029
I have tried to connect my index.php file in 000webhost.com using jQuery.
From the site menu I have connected with 000webhost using FTP details available in 000webhost.com.
When I tried to read data from jQuery it doesn’t working.
Anyone please tell me what should I need to change? Should I need to connect my Dreamweaver database to webhost? If yes please explain?
This is what I have done.
index.php
$mysql_host = "mysql0.000webhost.com";
$mysql_database = "a000000_mydb";
$mysql_user = "a000000_root";
$mysql_password = "******";
$conn=@mysql_connect ( $mysql_host,$mysql_user,$mysql_password )or die('aa');
mysql_select_db($mysql_database,$conn) or die('eoor on db');
$quer=mysql_query("SELECT * FROM sam");
$res=array();
while($row=mysql_fetch_row($quer)) {
$res[]=$row;
}
print(json_encode($res));
return json_encode($res);
mysql_close();
index.html
$.get('public_html/index.php', function( data ) {
alert( 'Successful' +data);
});