Lisa23 Posted September 3, 2011 Share Posted September 3, 2011 how can i replace ajax id with a variable? Postby jonathan » Sat Sep 03, 2011 4:14 pm Hi can i put the ajax div into a variable or instead of using get element by id can i use get element by $film the reason i want to do that is that have the 3 files the ajax function, the query file, and the display page now the display page display the ajax function using the (document.getElementById('ajaxFilmLink') so on the display page i have a div=ajaxFilmLink. this returns the value fine but my problem now is that instead of a div=ajaxFilmLink i want a variable that works just like the div=ajaxFilmLink because i need to store those values on jwplayer which usualy would be like this 'file': '<?php echo $efilm; ?>', i tried 'file': '<?php echo div=ajaxFilmLink ; ?>', but that doesnt work is there a way i can grab that ajax div value and store on a variable $efilm so that i can echo anywhere i want? my files 3 files are the follwings ajax file var ajaxRequest10; // The variable that makes Ajax possible! try {// Opera 8.0+, Firefox, Safari ajaxRequest10 = new XMLHttpRequest(); } catch (e) {// Internet Explorer Browsers try { ajaxRequest10 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { ajaxRequest10 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {// Something went wrong alert("Your browser broke!"); return false; } } } // ********** DATA 10 ********** FILM LINK // Create a function that will receive data sent from the server ajaxRequest10.onreadystatechange = function() { if(ajaxRequest10.readyState == 4) { var ajaxDisplay10 = document.getElementById('ajaxFilmLink'); ajaxDisplay10.innerHTML = ajaxRequest10.responseText; } } // var fid = document.getElementById('fid').value; var queryString10 = "?fid=" + fid; ajaxRequest10.open("GET", "../jrp/setfilmlink.php" + queryString10, true); ajaxRequest10.send(null); queryfile named (setfilmlink.php) <?php include("../../includes/config.php"); mysql_connect($db_address, $db_username, $db_password);mysql_select_db($db_name) or die(mysql_error()); $fid = $_GET['fid']; $fid = mysql_real_escape_string($fid); $query10 = "SELECT * FROM films WHERE (film_id = '$fid')"; $qry_result10 = mysql_query($query10) or die(mysql_error()); while($row10 = mysql_fetch_array($qry_result10)) { $urlfid="http://www.onfilm.biz/streaming/home/".$row10['client']."/".$row10['client_office']."/".$row10['filename'].".mp4";?> <a class="hofwhite14" href="#" onclick="loadNplay('<?php echo $urlfid; ?>')"><u></u>Property Film</u></a> <?php }mysql_close(); //EDIT 290510 ?> and the display page is named (indextest.php) <div id="ajaxFilmLink"> </div> the main reason i want to change is because when i simple try to put the query page on the indextest.php page the query doesnt retrieve the data from the database so can i put the ajax div into a variable or instead of using get element by id can i use get element by $film Link to comment https://forums.phpfreaks.com/topic/246355-how-can-i-replace-ajax-id-with-a-variable/ Share on other sites More sharing options...
sunfighter Posted September 3, 2011 Share Posted September 3, 2011 I think you want to know if the ajax return can be placed in a variable and not displayed. And you want to use that in a php code ===> 'file': '<?php echo $efilm; ?>', 'file': '<?php echo $efilm; ?>', is PHP and can't be done on the page, it's done on the server. You couldn't do it in the browser any way shape or form. Link to comment https://forums.phpfreaks.com/topic/246355-how-can-i-replace-ajax-id-with-a-variable/#findComment-1265123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.