Home > front end >  I am novice, consult about using Ajax technology to the background for all values of a field in a da
I am novice, consult about using Ajax technology to the background for all values of a field in a da

Time:01-13

Consult with Ajax technology to the background get all the value of a field in a database table, and then assign values to the aspx page, I am a novice, wish you a great god gives a complete example, online, etc., in this thanked

CodePudding user response:

HTML page code is a simple ajax access the backend interface, the background is interface to access the database, you want access to the content, and then returned to the ajax can, after the success of received data, it is ok to insert data into the page, (novice I suggest that you first take a look at how such technology is a principle of work, and the relationship between the content is what the code is how to execute),


 
$. Ajax ({
Type: 'get',
Url: "back office address,"
Data: {},
DataType: "json",
Success: the function (the req) {
The console. The log (the req)
}
});

 
<? PHP

$host="localhost";
$username='root';
$password=' ';
='database name' $database;

$pdo=new pdo (" mysql: host={$host}; Dbname={$database} ", $username, $password, array (PDO: : ATTR_PERSISTENT=& gt; True));
$pdo - & gt; Exec (" set names' utf8 ");

$info=$pdo - & gt; The query (' SQL statements) - & gt; FetchAll (PDO: : FETCH_ASSOC);

Echo json_encode ([' status'=& gt; '200', 'info'=& gt; $info]);
  •  Tags:  
  • ASP
  • Related