Results 1 to 7 of 7

Thread: javascript/ajax output format

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

    Default javascript/ajax output format

    hi, I have output code:

    PHP Code:
    function setOutput(){
        if(
    httpObject.readyState == 4){
            
    document.getElementById('outputText').value httpObject.responseText;
        }
     

    And the output is shown in the input place:

    PHP Code:
    <input type="text" name="outputText" id="outputText" /> 
    How I can get my output just as a text in <div></div> ???

    Thanks

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Similar to how you had it in your other recent post that I responded to:

    Code:
    document.getElementById("txtHint").innerHTML = httpObject.responseText;
    HTML Code:
    <div id="txtHint"></div>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    auriaks (03-10-2010)

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

    Default

    thanks
    Last edited by auriaks; 03-10-2010 at 06:13 PM.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    httpObject.open("GET", "../ajx_script/talpinimas.php?id=reklama&paveikslelis=" 
    +document.getElementById('paveikslelis').value+"&nikas="+<?php echo $nick; ?>
    This assumes you've already done:

    PHP Code:
    $nick $_SESSION['nikas']; 
    earlier in the code and that the page is being parsed as .php.

    However, if all you need is the value of $_SESSION['nikas'] be available on talpinimas.php, you could do it instead by taking it directly from the session variable on that page.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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

    Default

    OK, thanks again

    Other thing...

    I have youtube link like which user inserts into input, like:

    PHP Code:
    http://www.youtube.com/watch?v=oOzuBOefL8I&feature=topvideos 
    And I need to get some part of this link as a variable which could add with <?php echo "$variable";?> in other place.

    The part would be
    PHP Code:
    oOzuBOefL8I 

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Not sure what you mean by "other place". You cannot get the value of v in:

    http://www.youtube.com/watch?v=oOzuBOefL8I&feature=topvideos

    into PHP without either:

    • Submitting it to a page via a form. Or
    • Doing something we've been discussing like an AJAX request to another PHP page.

    But regardless of the method, it won't be available to PHP on the page you send it from, the PHP has already been parsed on that page. If you need it on that page, it could be gotten via javascript alone and then inserted via javascript alone wherever it's needed on that page. You could even do both, get and use it on the page with javascript, while also sending it to PHP via AJAX or a form submission for later use by PHP on other pages or even the next load of the current page.

    Where's this "other place"?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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

    Default

    I will submit the data as I did before... line of operations looks like this:

    inserting URL --> sending it to file.php --> read the part of URL and save it. That is all.

    I am using Ajax just to send information, but everything works in other page: file.php (converting, ysql_real_escape_string, saving, etc...)

    Do you need more specific info or a scipt part?

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
  •