anton578 Posted September 24, 2008 Share Posted September 24, 2008 is there a way to pass javascript array variable to php variable without reloading the page? Link to comment https://forums.phpfreaks.com/topic/125559-javascript-variable-to-php-variable/ Share on other sites More sharing options...
xtopolis Posted September 24, 2008 Share Posted September 24, 2008 Yes and no. Yes you can pass a var to php, using AJAX, and it doesn't have to reload the page, but it won't change anything on the page unless you tell it to... No, are you sure the purpose of this is logically correct? Explain what you're trying to do... Link to comment https://forums.phpfreaks.com/topic/125559-javascript-variable-to-php-variable/#findComment-649186 Share on other sites More sharing options...
anton578 Posted September 24, 2008 Author Share Posted September 24, 2008 Yes and no. Yes you can pass a var to php, using AJAX, and it doesn't have to reload the page, but it won't change anything on the page unless you tell it to... No, are you sure the purpose of this is logically correct? Explain what you're trying to do... thanks for the reply... im sorry im new to this can you give me an example of ajax on how to pass variable without reloading page... my purpose is im gonna need that javascript variable to be a php variable so i can use that variable for my php script... Link to comment https://forums.phpfreaks.com/topic/125559-javascript-variable-to-php-variable/#findComment-649244 Share on other sites More sharing options...
xtopolis Posted September 24, 2008 Share Posted September 24, 2008 If you're submitting a form, set the javascript value to a hidden field <script type="text/javascript"> document.write('<input type="hidden" name="fromJS" value="'+ myVal +'">'); </script> Otherwise, please visit the ajax board, there are links for tutorials there, or they are searchable online. Link to comment https://forums.phpfreaks.com/topic/125559-javascript-variable-to-php-variable/#findComment-649248 Share on other sites More sharing options...
anton578 Posted September 24, 2008 Author Share Posted September 24, 2008 ok thanks for the help... Link to comment https://forums.phpfreaks.com/topic/125559-javascript-variable-to-php-variable/#findComment-649263 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.