rshadarack Posted May 18, 2008 Share Posted May 18, 2008 I have a bunch of data in some client-side javascript code that I want to get to php code. I would typically just manually build the url string to send it over in GET, but because of the amount of data, this is not possible. So as far as I know, the only other method I have is to use POST. And the only way I know how to do this is to build a form by adding elements to the dom and submit it. However, this is rather ugly, is there any easier way? Quote Link to comment https://forums.phpfreaks.com/topic/106213-solved-data-from-javascritp-to-php/ Share on other sites More sharing options...
Wolphie Posted May 18, 2008 Share Posted May 18, 2008 Bear in mind that PHP is a server side language and JavaScript is a client side language. You could communicate with the server using Ajax, and add some nifty effects in to make it look no so *ugly*. Try googling jQuery. Quote Link to comment https://forums.phpfreaks.com/topic/106213-solved-data-from-javascritp-to-php/#findComment-544419 Share on other sites More sharing options...
resago Posted May 18, 2008 Share Posted May 18, 2008 if thats not your forte, you can use hidden iframes. Quote Link to comment https://forums.phpfreaks.com/topic/106213-solved-data-from-javascritp-to-php/#findComment-544469 Share on other sites More sharing options...
rshadarack Posted May 18, 2008 Author Share Posted May 18, 2008 From my understanding, hidden iframes are used to have persistent data in javascript, but you can't use one to transfer data from javascript to php. Is that correct? I didn't realize this before, but the size of the arrays I have to transfer can be determined when the php script is running. So I can create a hidden form by just using php to make html instead of modifying the dom, and then submit it by javascript code (I think?) which will send the data needed in POST. Quote Link to comment https://forums.phpfreaks.com/topic/106213-solved-data-from-javascritp-to-php/#findComment-544490 Share on other sites More sharing options...
rshadarack Posted May 19, 2008 Author Share Posted May 19, 2008 Implemented it, and it wasn't bad, though it still makes me feel a little... dirty. Quote Link to comment https://forums.phpfreaks.com/topic/106213-solved-data-from-javascritp-to-php/#findComment-544546 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.