GuitarGod Posted August 16, 2013 Share Posted August 16, 2013 Hi all, I'm currently using jQuery's load function to send/load data into a page element, but I'm having trouble figuring out how to send dynamic data. var option_count = $( '#opt_count' ).val(); // This number is subject to change on every page var opts = ''; for ( i = 0; i < option_count; i++ ) { opts = opts+'&option_'+i+'='+$( '#option_'+i ).val(); } // So the data above could be &option_0=7&option_1=4&option_2=9 etc // but I can't seem to send option as an individual parameter // I've tried $( '#contain' ).load( 'receiver.php', { page_no : "2"+opts, }); // I've also tried $( '#contain' ).load( 'receiver.php', { page_no : "2", opts }); // What I'm trying to convey is $( '#contain' ).load( 'receiver.php', { page_no : "2", option_0 : 7, option_1 : 4 // etc etc.. }); However, the number of options and their values are dynamic and subject to change. Any ideas? Link to comment https://forums.phpfreaks.com/topic/281241-sending-dynamic-content-with-jquery/ Share on other sites More sharing options...
nogray Posted August 16, 2013 Share Posted August 16, 2013 Since you are making a query URL, just added the options to your link e.g. 'receiver.php?'+opts Link to comment https://forums.phpfreaks.com/topic/281241-sending-dynamic-content-with-jquery/#findComment-1445406 Share on other sites More sharing options...
kicken Posted August 16, 2013 Share Posted August 16, 2013 var option_count = $( '#opt_count' ).val(); // This number is subject to change on every page var opts = {page_no:2}; for ( i = 0; i < option_count; i++ ) { opts['option_'+i] = $('#option_'+i).val(); } $( '#contain' ).load('receiver.php', opts); Create the opts object with the page_no option to start, then add each option_x property in the loop. Link to comment https://forums.phpfreaks.com/topic/281241-sending-dynamic-content-with-jquery/#findComment-1445408 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.