SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    15
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    jwplayer donít work when using Ajax script

    Hope someone can help me.

    Iím building up a small and simple CMS. In the CMS there is a movie and a photo page where a thumb of the photo or movie is loaded in the right side of the page and in the left side the photo or movie is showed.

    The left side where the movie or photo is showed is loaded using an Ajax script. The Issue is that the movies donít show up. Iím using jwplayer to show movies. Itís loaded dynamic by an auto generated link:

    HTML Code:
    <a href=\"javascript:ajaxpage('movie-view.php?var1=" .$mov1. "&var2=" . $displayMovieLowPath ."', 'rightcolumn');\">Watch movie 1</a>

    The Ajax code looks like this (I have not written this myself!):

    PHP Code:
    <script type="text/javascript">
    /***********************************************
    * http://dynamicdrive.com/dynamicindex17/ajaxcontent.htm
    ***********************************************/
    var loadedobjects=""
    var rootdomain="http://"+window.location.hostname
    function ajaxpage(urlcontainerid){
    var 
    page_request false
    if (window.XMLHttpRequest// if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (
    window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")

    catch (
    e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (
    e){}
    }
    }
    else
    return 
    false
    page_request
    .onreadystatechange=function(){
    loadpage(page_requestcontainerid)
    }
    page_request.open('GET'urltrue)
    page_request.send(null)
    }
    function 
    loadpage(page_requestcontainerid){ 
    if (
    page_request.readyState == && (page_request.status==200 || window.location.href.indexOf("http")==-1)) 
    document.getElementById(containerid).innerHTML=page_request.responseText

    function 
    loadobjs(){
    if (!
    document.getElementById)
    return
    for (
    i=0i<arguments.lengthi++){
    var 
    file=arguments[i]
    var 
    fileref=""
    if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
    if (file.indexOf(".js")!=-1){ //If object is a js file
    fileref=document.createElement('script')
    fileref.setAttribute("type","text/javascript");
    fileref.setAttribute("src"file);
    }
    else if (
    file.indexOf(".css")!=-1){ //If object is a css file
    fileref=document.createElement("link")
    fileref.setAttribute("rel""stylesheet");
    fileref.setAttribute("type""text/css");
    fileref.setAttribute("href"file);
    }
    }
    if (
    fileref!=""){
    document.getElementsByTagName("head").item(0).appendChild(fileref)
    loadedobjects+=file+" " //Remember this object as being already added to page
    }
    }
    }
    </script> 
    I think somehow the script donít send all info to the movie-view.php page that is loads using the Ajax.


    If I donít load the page using the Ajax script like this:
    HTML Code:
    <a href=\"movie-view.php?var1=" .$mov1. "&var2=" . $displayMovieLowPath ."\" target=new>Watch movie 1</a>
    The page open and load and the jwplayer works just fine.


    I think there needs to be add some codes to the Ajax script around this spot:

    PHP Code:
    function loadpage(page_requestcontainerid){ 
    if (
    page_request.readyState == && (page_request.status==200 || window.location.href.indexOf("http")==-1)) 
    document.getElementById(containerid).innerHTML=page_request.responseText

    But I have no idea of what to add or how the codes should look like.


    If itís a help/hint I had the same issue with photos where I use Shadowbox.js (http://www.shadowbox-js.com/) to show my photos. The Shadowbox did not show up when clicking a thumb on the page loaded using the Ajax script, then I add the this piece of code to the script: Shadowbox.setup(); so it ended look like this:

    PHP Code:
    function loadpage(page_requestcontainerid){ 
    if (
    page_request.readyState == && (page_request.status==200 || window.location.href.indexOf("http")==-1)) 
    document.getElementById(containerid).innerHTML=page_request.responseText
    Shadowbox.setup(); 



    Hope someone can help me getting the jwplayer work.

    THANKS

  2. #2
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    15
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Here comes a Little bonus info. It is the latest version 6.7 im using.

    The codes for calling the movie looks like:

    Code:
    <div id="myElement">Loading the player 6...</div>
    <script type="text/javascript">
    jwplayer("myElement").setup({
    file: "<? echo($_GET["var2"].$f4vfilenameext) ?>",
    height: 360,
    image: "/uploads/example.jpg",
    width: 640
    });
    </script>
    Hope someone can help

  3. #3
    Patience... bronze trophy solidcodes's Avatar
    Join Date
    Jul 2006
    Location
    Philippines
    Posts
    911
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    adding words

    @GertK ;
    I use jwplayer in my project and it's work fine.

    Everything is in the documentation, are you sure you are following the instructions properly?
    Last edited by solidcodes; Dec 22, 2013 at 21:30. Reason: I want to add words.
    I Love coding...
    Don't click this link.

  4. #4
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    15
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi, I think i do - thatss why I dont understand whay it does not Work. Do you have any suggestions?

  5. #5
    GrŁŖe aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,311
    Mentioned
    177 Post(s)
    Tagged
    8 Thread(s)
    Hey there,

    Could you post a link to a page where we can see this in action.
    Although not coded very elegantly, the AJAX itself looks ok, so it would really help to see a demo of this not working.

  6. #6
    GrŁŖe aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,311
    Mentioned
    177 Post(s)
    Tagged
    8 Thread(s)
    Hi,

    Got your PM.
    On the page you are having the error on, when you click on a link to get a video, the console is reporting:

    Code:
    ReferenceError: getRenderingMode is not defined - movies.php line 182
    That is a good place to start looking.

  7. #7
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    15
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Thanks, what program or how does you use to see that?

  8. #8
    GrŁŖe aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,311
    Mentioned
    177 Post(s)
    Tagged
    8 Thread(s)
    You go to the page where you are getting the error open the console in your broswer's dev tools (how do I do that?) and click on the link that is producing the error.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •