Results 1 to 2 of 2

Thread: Javascript var to php

  1. #1
    Join Date
    Aug 2009
    Posts
    399
    Thanks
    42
    Thanked 4 Times in 4 Posts

    Default Javascript var to php

    Hi,

    I was creating AJAX script for my website and it works fine

    But then I faced problem. My AJAX output function is below:

    Code:
    function setOutput(){
        if(httpObject.readyState == 4){ 
            var answer = eval('(' + httpObject.responseText + ')');
            document.getElementById('vardas2').innerHTML = answer[0]; 
            document.getElementById('pavarde2').innerHTML = answer[1];
    		document.getElementById('emailas2').innerHTML = answer[2];
    		document.getElementById('reemailas2').innerHTML = answer[3];
    		document.getElementById('slaptazodis2').innerHTML = answer[4];
    		document.getElementById('reslaptazodis2').innerHTML = answer[5];
    		document.getElementById('date2').innerHTML = answer[6];
        } 
     
    }
    I want to get use of variable answer[0] in my php script.

    How I can do it?

    Btw, I tried to use:
    PHP Code:
    <?php
    $java_vardas 
    $_POST['vardas2'];
    echo 
    $java_vardas;
    ?>
    but it does not work...

    Please help me with this.
    Kind regards, auriaks.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    PHP is loaded first it can't be used with javascript directly. What function are you trying to use it sometimes is easier to just do it all in JS?
    Corrections to my coding/thoughts welcome.

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
  •