Lisa23 Posted September 2, 2011 Share Posted September 2, 2011 var ajaxRequest4; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest4 = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest4 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest4 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // ********** DATA 04 ********** VIDEO // Create a function that will receive data sent from the server ajaxRequest4.onreadystatechange = function(){ if(ajaxRequest4.readyState == 4){ var ajaxDisplay4 = document.getElementById('ajaxDivVideo'); ajaxDisplay4.innerHTML = ajaxRequest4.responseText; loadNplay(document.getElementById('myvideourladdr').value); } } // var fid = document.getElementById('fid').value; var queryString4 = "?fid=" + fid; ajaxRequest4.open("GET", "../jrp/readpropertyvideo.php" + queryString4, true); ajaxRequest4.send(null); Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/ Share on other sites More sharing options...
AyKay47 Posted September 2, 2011 Share Posted September 2, 2011 looks like it is establishing an asynchronous connection to the server using AJAX method.. sends data to the given url, and places the response into the element with id = ajaxDivVideo.. also applies a custom function.. Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264671 Share on other sites More sharing options...
Lisa23 Posted September 2, 2011 Author Share Posted September 2, 2011 Thank you one more question this might be a mix of php the ur from that ajax is readpropertyvideo.php now on this page i have the above script which works fine my question is? is there a way on that same ajax script that i can get it to send to 2 different url like at moment it is going to readpropertyvideo.php how can i get so that it also goes to indextest.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); $query4 = "SELECT * FROM films WHERE (film_id = '$fid')"; $qry_result4 = mysql_query($query4) or die(mysql_error()); while($row = mysql_fetch_array($qry_result4)) { $myfilmurlstr = "http://www.onfilm.biz/streaming/home/$row[film_client]/$row[film_client_office]/$row[film_filename].mp4"; $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; } mysql_close(); //EDIT 290510 echo $display_string4;?> Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264672 Share on other sites More sharing options...
AyKay47 Posted September 2, 2011 Share Posted September 2, 2011 to my knowledge, you cannot have two open() methods in one ajax request, could be mistaken.. I believe that you would have to create another AJAX call in the same function to get your desired functionality.. also, I recommend using jquery's AJAX API instead of standard js Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264674 Share on other sites More sharing options...
Lisa23 Posted September 2, 2011 Author Share Posted September 2, 2011 Do you mean doing something like duplicat this part but with a differenr url instead of jrp/readpropertyvideo.php one with bellway/indextest.php ajaxRequest4.onreadystatechange = function(){ if(ajaxRequest4.readyState == 4){ var ajaxDisplay4 = document.getElementById('ajaxDivVideo'); ajaxDisplay4.innerHTML = ajaxRequest4.responseText; loadNplay(document.getElementById('myvideourladdr').value); } } // var fid = document.getElementById('fid').value; var queryString4 = "?fid=" + fid; ajaxRequest4.open("GET", "../bellway/indextest.php" + queryString4, true); ajaxRequest4.send(null); so the overall code would be like?? var ajaxRequest4; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest4 = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest4 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest4 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // ********** DATA 04 ********** VIDEO // Create a function that will receive data sent from the server ajaxRequest4.onreadystatechange = function(){ if(ajaxRequest4.readyState == 4){ var ajaxDisplay4 = document.getElementById('ajaxDivVideo'); ajaxDisplay4.innerHTML = ajaxRequest4.responseText; loadNplay(document.getElementById('myvideourladdr').value); } } // var fid = document.getElementById('fid').value; var queryString4 = "?fid=" + fid; ajaxRequest4.open("GET", "../jrp/readpropertyvideo.php" + queryString4, true); ajaxRequest4.send(null); // SEND TO SECOND URL ajaxRequest4.onreadystatechange = function(){ if(ajaxRequest4.readyState == 4){ var ajaxDisplay4 = document.getElementById('ajaxDivVideo'); ajaxDisplay4.innerHTML = ajaxRequest4.responseText; loadNplay(document.getElementById('myvideourladdr').value); } } // var fid = document.getElementById('fid').value; var queryString4 = "?fid=" + fid; ajaxRequest4.open("GET", "../bellway/indextest.php" + queryString4, true); ajaxRequest4.send(null); Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264677 Share on other sites More sharing options...
Lisa23 Posted September 2, 2011 Author Share Posted September 2, 2011 You might be right but i don't think i've actually lay out my problem propelly this my issue I have a the following site http://www.estateagentsonfilm.co.uk/tv/bellway/indextest.php# the site uses a jwplayer and php to load the video into the player this how the php load the video into the player the full script bellow but this the line that loads the $efilm="http://www.onfilm.biz/streaming/home/".$client."/".$client.".mp4"; and on the player i'll have the <?php echo $efilm; ?> Now this is the first movie the player picks up but what i am trying to figure out is when you click a different propriety from the link above it plays a different video what i wanted to know how is that that video gest load into the player when i only have the first video onto the player which is <?php echo $efilm; ?> i do have other files but they written in ajax which which i don't really understand if anyone here understand ajax i can send all three files to have a look if possible thanks in advance ?php $playme = "true"; ?> <?php // $playme=1; if($efilm=="") { $efilm="http://www.onfilm.biz/streaming/home/".$client."/".$client.".mp4"; } else { // nothing } ?> include("../../includes/config.php"); //connect to DB $connectionci = @mysql_connect($db_address,$db_username,$db_password) or die("Couldn't CONNECT."); $dbci = @mysql_select_db($db_name, $connectionci) or die("Couldn't select DATABASE."); //SELECT All based on current cookie Information $queryci="SELECT * FROM clients WHERE (client_company = '$client')"; $resultci = mysql_query($queryci) or die("Couldn't execute QUERY."); while ($rowci = mysql_fetch_array($resultci)) { $client_name = $rowci[client_company_name]; $client_addr_01 = $rowci[client_address01]; $client_addr_02 = $rowci[client_address02]; $client_addr_city = $rowci[client_city]; $client_addr_county = $rowci[client_county]; $client_addr_postcode = $rowci[client_postcode]; $client_addr_telephone = $rowci[client_telephone]; $client_addr_email = $rowci[client_email]; $client_url = $rowci[client_url]; } mysql_close($connectionci); ?> <script type="text/javascript" src="../jwplayer/jwplayer.js"></script> <script type="text/javascript"> jwplayer("mediaplayer").setup({ 'flashplayer': '../jwplayer/player.swf', 'id': 'playerID', 'width': '640', 'height': '360', 'file': '<?php echo $efilm; ?>', 'skin': '../jwplayer/glow.zip', 'dock': 'false', 'viral.oncomplete': 'false', 'hd.state': 'false', 'viral.allowmenu': 'false', autostart: true, 'plugins': { 'hd-1': { file: '<?php echo $stream="http://www.onfilm.biz/streaming/home/$row[film_client]/$row[film_client_office]/$row[film_filename].mp4"; ?>' } } }); var player = null; function playerReady(obj) { player = document.getElementsByName(obj.id)[0]; } function loadNplay(file) { if(player!=null){ player.sendEvent('LOAD', {file:file, type:'video'}); player.sendEvent('PLAY', 'true'); } } function playerStart(file) { player.sendEvent('PLAY',true); } function playerStop(file) { player.sendEvent('STOP'); } function playerPause(file) { player.sendEvent('PLAY',false); } </script> <script> //call after page loaded window.onload=function(){ ajaxFunction1(); setTimeout("createPlayer()",2000); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264742 Share on other sites More sharing options...
Lisa23 Posted September 2, 2011 Author Share Posted September 2, 2011 Thanks for the help! why is that when i try to do same query on different pages one queries from the database but the other one doesnt retrieve the data from the database readopropertyvideo.php script <?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); $query4 = "SELECT * FROM films WHERE (film_id = '{$fid}')"; $qry_result4 = mysql_query($query4) or die(mysql_error()); while($row = mysql_fetch_array($qry_result4)) { $myfilmurlstr = "http://www.onfilm.biz/streaming/home/$row[film]/$row[client_office]/$row[filename].mp4"; $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; } mysql_close(); //EDIT 290510 echo $display_string4;?> result correct readopropertyvideo.php url shows correct http://www.onfilm.biz/streaming/home/film/clientoffice/filename.mp4 now i tried a similiar script on the indextest.php but it doesnt query from the database its shows http://www.onfilm.biz/streaming/home///.mp4 <?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); $query4 = "SELECT * FROM films WHERE (film_id = '{$fid}')"; $qry_result4 = mysql_query($query4) or die(mysql_error()); while($row = mysql_fetch_array($qry_result4)) { $myfilmurlstr = "http://www.onfilm.biz/streaming/home/$row[film]/$row[client_office]/$row[filename].mp4"; $display_string4 .= "<input name='myvideourladdr' type='hidden' id='myvideourladdr' value='$myfilmurlstr' size='72'>"; } mysql_close(); //EDIT 290510 echo $display_string4;?> Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264771 Share on other sites More sharing options...
AyKay47 Posted September 2, 2011 Share Posted September 2, 2011 1. no errors triggered by the mysql_query..? 2. the parenthesis around the WHERE clause statement are not needed.. 3. try outputting $qry_result4 to make sure your query is what you expect.. 4. you can also use mysql_num_rows() to see how many rows your query is grabbing.. 5. place quotes around your indices.. good practice.. $row['film'] not $row[film] Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264774 Share on other sites More sharing options...
Lisa23 Posted September 2, 2011 Author Share Posted September 2, 2011 No i get no error you can see the outcome on the link bellow all of those property links are from that same query which works fine but the query comes from the page file readpropertyvideo.php http://www.estateagentsonfilm.co.uk/tv/bellway/indextest.php but when i try the same query by putting the exact same query on the index.php the data are not retrieved. Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264794 Share on other sites More sharing options...
Lisa23 Posted September 2, 2011 Author Share Posted September 2, 2011 i do suspect the reason why the script will only work on the readpropertyvideo.php is because on this ajax code bellow thers a GET statement that says to readpropertyvideo.php, but i tried to change to indextest.php but still doesnt run? the code only seems to run with the readpropertyvideo.php. I can then grab the url link from when the user clicks and store on another variable since the way i am trying to do is not queyring?? // Create a function that will receive data sent from the server ajaxRequest4.onreadystatechange = function(){ if(ajaxRequest4.readyState == 4){ var ajaxDisplay4 = document.getElementById('ajaxDivVideo'); ajaxDisplay4.innerHTML = ajaxRequest4.responseText; loadNplay(document.getElementById('myvideourladdr').value); } } // var fid = document.getElementById('fid').value; var queryString4 = "?fid=" + fid; ajaxRequest4.open("GET", "../jrp/readpropertyvideo.php" + queryString4, true); ajaxRequest4.send(null); Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264800 Share on other sites More sharing options...
AyKay47 Posted September 2, 2011 Share Posted September 2, 2011 as i stated previously.. you need to make two spearate ajax requests here..one for each url Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264803 Share on other sites More sharing options...
Lisa23 Posted September 2, 2011 Author Share Posted September 2, 2011 i dont really understand about ajax but ok this how i am thinking creating 2 ajax function do i just change the url but keep the same fuction exacly how they are?? function one to the url readpropertyvideo var ajaxRequest4; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest4 = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest4 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest4 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // ********** DATA 04 ********** VIDEO // Create a function that will receive data sent from the server ajaxRequest4.onreadystatechange = function(){ if(ajaxRequest4.readyState == 4){ var ajaxDisplay4 = document.getElementById('ajaxDivVideo'); ajaxDisplay4.innerHTML = ajaxRequest4.responseText; loadNplay(document.getElementById('myvideourladdr').value); } } // var fid = document.getElementById('fid').value; var queryString4 = "?fid=" + fid; ajaxRequest4.open("GET", "../jrp/readpropertyvideo.php" + queryString4, true); ajaxRequest4.send(null); Jax function 2 var ajaxRequest4; // The variable that makes Ajax possible! try{ // Opera 8.0+, Firefox, Safari ajaxRequest4 = new XMLHttpRequest(); } catch (e){ // Internet Explorer Browsers try{ ajaxRequest4 = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try{ ajaxRequest4 = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){ // Something went wrong alert("Your browser broke!"); return false; } } } // ********** DATA 04 ********** VIDEO // Create a function that will receive data sent from the server ajaxRequest4.onreadystatechange = function(){ if(ajaxRequest4.readyState == 4){ var ajaxDisplay4 = document.getElementById('ajaxDivVideo'); ajaxDisplay4.innerHTML = ajaxRequest4.responseText; loadNplay(document.getElementById('myvideourladdr').value); } } // var fid = document.getElementById('fid').value; var queryString4 = "?fid=" + fid; ajaxRequest4.open("GET", "../tv/indextest.php" + queryString4, true); ajaxRequest4.send(null); Quote Link to comment https://forums.phpfreaks.com/topic/246264-can-someone-explain-what-this-code-trying-to-do/#findComment-1264810 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.