SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Ajax Beginner

  1. #1
    SitePoint Wizard rctneil's Avatar
    Join Date
    Jun 2005
    0 Post(s)
    0 Thread(s)

    Question Ajax Beginner

    I ahve never written any javascript or ajax before so this is completely new to me. I ahve read the following link:

    and downloaded their script and integrated to a page on my local devlopment server.

    I have this code:

    HTML Code:
    	<div class="tab_blend1"></div>
    <div id="multimedia"></div>
    <a onclick="ajax_loadContent('multimedia','includes/');">Clicky</a>
    <a onclick="ajax_loadContent('multimedia','includes/');">Clicky 2</a>
    and when I click the two links the content in the <div> above changes dynamically which is great.

    The problem is that the pages I linked to (ie: the ones I wnat to show up in the div) use php variables from the page the ajax is on and when the content loads in the div I just get a whole load of php errors as the new content cannot find the php variables and mysql query results and so on. Does this mean that each of the pages I want to bring in via ajax have to be self contained? or is there a way to sort this out?

    Also, How can I get the page with the ajax on to bring in all the called in pages 1 underneath another if the user has javascript turned off?



  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    0 Post(s)
    0 Thread(s)
    Ajax does a request like a web browser would. If going to the url in your browser doesn't work, it won't work having ajax do it either. There is nothing magical happening here, the browser just fetches the webpage in the background.

    Make your webpage work without any javascript. Let javascript enhance the functionality or usability. In your case, thsi means output all the content always. If you want javascript to hide it, so that it can then show it to users when they click on a link, thats ok.


Posting Permissions

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