SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict pkSML's Avatar
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    AJAX question for noob

    Hello. I have just started toying around with Ajax this week. What I want to do is simple.

    I have 1.php and 2.php.
    1.php is the original document.
    2.php is requested via AJAX.

    I want 2.php to be able to change the innerHTML of a span located in 1.php.

    Here is 2.php
    Code:
    <SCRIPT language="JavaScript">
    document.getElementById('boldStuff').innerHTML = 'Fred Flinstone';
    </SCRIPT>
    The problem is that this code seems to do nothing. How can the JavaScript in 2.php interact with 1.php?

    Please remember I'm new to AJAX and really don't have much to start with.
    Any links or tutorials that you'd recommend would be appreciated.
    Thanks!
    -Stephen

    Get a LitlURL to this page!

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    2.php cannot change the contents of 1.php

    Through AJAX, 1.php can make a request from 2.php

    2.php can then respond and print out a text response, which is then returned, so that 1.php can do something with it.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Addict pkSML's Avatar
    Join Date
    Aug 2006
    Location
    Ohio
    Posts
    230
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK. Thanks for that information! I would've been searching for days before reaching that conclusion.

    I happened to find this article: http://www-128.ibm.com/developerwork...ro2/index.html
    (The whole series is here --> http://www.ibm.com/developerworks/vi...Mastering+Ajax )

    It explained exactly what I needed to do and I got it working just the way I wanted!

    Here's the link: http://pksml.net/antipixel_ajax
    -Stephen

    Get a LitlURL to this page!


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
  •