PHP And Javascript

Discussion in 'JavaScript' started by glasglow, Jun 19, 2007.

  1. #1
    I have a .js file calling a page title (document.title) and would like to use that title as a variable like:

    $star = the.js;

    What I am trying to do is bring the output from the .js file into the php file as the data for the variable. Is it possible?
     
    glasglow, Jun 19, 2007 IP
  2. Mike H.

    Mike H. Peon

    Messages:
    219
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use AJAX to do that. process.php, is a separate document, it cannot be the same as the document.title one.

    function processTitle(){
    
    	var AdminRequest = window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();   
    	var nTitle = "?title=" + document.title;
    	AdminRequest.open("GET", "process.php"+nTitle, true);
    	AdminRequest.send(null); 
    }
    Code (markup):
    
          $star = $_GET['title'];
    Code (markup):
     
    Mike H., Jun 19, 2007 IP
    glasglow likes this.
  3. glasglow

    glasglow Active Member

    Messages:
    926
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #3
    Thanks I'll try it out.
     
    glasglow, Jun 19, 2007 IP