TeddyKiller Posted May 15, 2010 Share Posted May 15, 2010 My code is below. I'm wanting to pass the php variable $db, to the function called. The line where I'm having issues is db: <?php echo $db ?> $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val() db: <?php echo $db ?> }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); How can it be done? Thanks Link to comment https://forums.phpfreaks.com/topic/201870-passing-php-variable-to-a-function-called-in-jquery-ajax-help/ Share on other sites More sharing options...
CodeMaster Posted May 15, 2010 Share Posted May 15, 2010 You need to put quotes around the value and a comma on the line above. Like this: $(document).ready(function() { $('#wait_1').hide(); $('#drop_1').change(function(){ $('#wait_1').show(); $('#result_1').hide(); $.get("func.php", { func: "drop_1", drop_var: $('#drop_1').val(), db: "<?php echo $db ?>" }, function(response){ $('#result_1').fadeOut(); setTimeout("finishAjax('result_1', '"+escape(response)+"')", 400); }); return false; }); }); Link to comment https://forums.phpfreaks.com/topic/201870-passing-php-variable-to-a-function-called-in-jquery-ajax-help/#findComment-1058868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.