Jump to content

Recommended Posts

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.