M
M
Mopaa2018-06-04 15:21:29
PHP
Mopaa, 2018-06-04 15:21:29

How to work with a database in JS + PHP?

In a program that is written in JS, subject to the conditions, there should be a record in the mysql database, I want to use php to work with the database, how to implement such a design?
if ( a == b ){ // This is JS
<?php
//Here will work with the database on php
?>
}
// Then again JS

Answer the question

In order to leave comments, you need to log in

3 answer(s)
W
Web Dentist, 2018-06-04
@Mopaa

$.ajax({
  url: "index.php", 
  context: $( ".myClass" ), 
  success: function(){ 
    alert('ok');
  }
});

And on the server side, you route index.php and do what you need

N
netrox, 2018-06-04
@netrox

In such cases, use AJAX.

V
Vladimir, 2018-06-04
@Bigata

if ( a == b ){
//ajax request to the server script in php => the script does something (for example, works with the database) and returns the response to the client.
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question