Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

communication between PHP and Javascript

Tags:

javascript

php

I want to send some data to Javascript from PHP.(these two file is different file in same folder) For example, If I calculate some value in PHP side, I want to send the data to javascript and I use the data. How can I do this??

like image 912
Jimmy Avatar asked Dec 09 '12 20:12

Jimmy


People also ask

Can JavaScript and PHP work together?

Besides, PHP and JavaScript similarities, these two languages are a powerful combination when used together. Large numbers of websites combine PHP and JavaScript – JavaScript for front-end and PHP for back-end as they offer much community support, various libraries, as well as a vast codebase of frameworks.

Why is it not possible for JavaScript and PHP to interact directly?

JavaScript is a client-side scripting language. This means that the server does not execute JavaScript, only the web browser does. JavaScript cannot directly interact with PHP because the PHP will always be executed first by the server and then sent to the client's browser. JavaScript can only pass information to PHP.

Is JavaScript needed for PHP?

Both JavaScript and PHP are general-purpose scripting languages suited for web development. However, JavaScript is a client-side scripting language and PHP is a server-side scripting language. The two languages can be used independently and collaboratively, and they can do wonders combined.

What are the similarities between JavaScript and PHP?

Similarities Between PHP and JavaScript Now, have a look at the similarities between the two: Both the languages are object-oriented, they are easy to use and understand. They are both case sensitive to variables, and both the languages call Hypertext transfer protocol to execute a program.


1 Answers

There's complete technology for that called AJAX with a lot of tutorials on the internet.

And there's already a great and easy-to-deploy implementation - within jQuery.

like image 110
Vyktor Avatar answered Sep 18 '22 14:09

Vyktor