ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Joel Foba , Developper /Administrateur sustème , World Engineering Consulting Internationale (WEC)
تاريخ النشر: 2013/12/04
Fadi Alkhateeb
من قبل 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
من قبل 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
من قبل 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.

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟