R
R
Rishat Sultanov2017-05-06 14:46:53
JavaScript
Rishat Sultanov, 2017-05-06 14:46:53

How to connect JS with PHP correctly?

Good afternoon, gentlemen :)
I want to use the insert () method at the DB facade every 2 seconds and looked towards JS, but I can’t figure out how to shove the pykher code into JS, I found options with variables, but I think that’s how they do it somehow not right.
Found an example:

<script language=javascript>
var jsvar;

jsvar = <?php echo $phpvar;?>
</script>

What I'm trying to put in:
DB::table('zagon_all')->insert(
    ['id' => '']
    );

var timerId = setInterval(function() {
 // Сюды хочу засунуть данную тему с добавлением данных в БД
 }, 2000);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
entermix, 2017-05-06
@rishatss

State? How PHP (server-side language) should work in your browser? Are you out of your mind?
Make a server side handler and use AJAX requests to do something

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question