Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

Can anyone tell me how can i get the value of a variable in jquery then control it at the level of server with php?

user-image
Question ajoutée par Joel Foba , Developper /Administrateur sustème , World Engineering Consulting Internationale (WEC)
Date de publication: 2013/12/04
Fadi Alkhateeb
par Fadi Alkhateeb , Senior Front End Developer , NexTwo

You will need to use Ajax in Jquery to pass the javascript variable to a php script and use it whatever you want.

 

Below is a declaration for  Ajax() in jQuery:

ajax()

 

 

 

Muhammad Majid Saleem
par Muhammad Majid Saleem , Senior PHP Developer / Project Manager , SwaamTech

You can do this using an Ajax call. Please find an example below:

 

<script type="text/javascript" language="javascript">

$(document).ready(function(){

 

// get your variable values upon some action or as per your desire. I am assuming you clicked a button to get some variable value.

$("#submit").click(function(){

var fullname = $("#fullname").val();

 

// Send an ajax call.

$.post("example.php", { fullname :fullname } , function( data ){       

    // Do something as per your logic.}, "json");

});

});

});

</script>

 

exmple.php<?php$fullname = $_POST['fullname'];

// Now you can use it on server side as you want.?>

Asif Ali M
par Asif Ali M , Project Lead , LiquidHub

There is a possibility of sending a javascript variable to php. You need to explain what exactly you are trying to do.

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?