SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 31 of 31
  1. #26
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks but removing
    Code:
    <div id="single-home-container"></div>
    from test.php doesn't seem to make a difference.
    Header.php
    Code:
    <script>
    $(document).ready(function(){      
    	$.ajaxSetup({cache:false});     
    	$(".locationID").click(function(){         
    		var post_id = $(this).attr("rel"); 
    		//alert($(this).attr('rel'));
    		$("#single-home-container").html("loading...");         
    		$("#single-home-container").html(post_id);
    		
    		$("#single-home-container").load("test.php", { 'locationID': $(this).attr("rel") } );
    		
    		//$.post("test.php", {"locationID": post_id}, function (txt) {
    		//	alert(txt);
    		//});
    
    		return false;    
    	});  
    }); 
    </script>
    footer.php has the loop tp produce the links:
    Code:
    			<?php	
    			$args = array( 
    						  'post_type' => 'locations', 
    						  'order'    => 'DESC'
    						  );
    			$loop = new WP_Query( $args );
    			while ( $loop->have_posts() ) : $loop->the_post();
    			?>	
    				<li><a href="#" rel="<?php the_ID(); ?>" class="locationID"><?php the_title(); ?></a></li>
    			<?php	
    			endwhile;	
    			wp_reset_query();
    			?>
    Also is the include to test.php
    Code:
    <?php include(TEMPLATEPATH."/test.php"); ?>
    Test.php has this to check the value
    Code:
    <?php 
    $the_location_id1 = $_GET['locationID'];
    echo '<br>Loc ID '. $the_location_id1;
    ?>
    And the main query I wish to pass the value to:
    Code:
    			<?php	
    			$args = array( 
    						  'post_type' => 'locations', 
    						  'posts_per_page' => 1,
    						  'p' => $the_location_id1 ,
    						  );
    			$loop = new WP_Query( $args );
    			while ( $loop->have_posts() ) : $loop->the_post();
    			?>	
    			<?php the_title(); ?>
    			<?php	
    			endwhile;	
    			wp_reset_query();
    			?>
    Which i believe is the right set up from what's been posted so far!?
    Thanks again, it really is appreciated

  2. #27
    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)
    Quote Originally Posted by jarv01980 View Post
    Thanks again, it really is appreciated
    Check to find out how far things get before they start working.

    1. Does the click event get triggered?
    2. Is the value in the REL attribute successfully retrieved?
    3. Is a request sent for the test.php file?
    4. Does the $_GET variable contain the expected information?
    5. Is test.php outputting something that can be used?


    That is the order in which you need to to check things out.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #28
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1.Does the click event get triggered? - Yes
    2.Is the value in the REL attribute successfully retrieved? - Yes, I've got
    Code:
    alert($(this).attr('rel'));
    which shows the value
    3.Is a request sent for the test.php file? Yes as I've got
    Code:
    <div id="single-home-container"></div>
    this shows the value
    4.Does the $_GET variable contain the expected information? No as this code isn't outpuuting a value
    Code:
    $the_location_id1 = $_GET['locationID'];
    echo '<br>Loc ID '. $the_location_id1;
    5.Is test.php outputting something that can be used? See point 4

    It's so close, it must be!?

    Thanks again.

  4. #29
    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)
    Quote Originally Posted by jarv01980 View Post
    1.Does the click event get triggered? - Yes
    2.Is the value in the REL attribute successfully retrieved? - Yes, I've got
    Code:
    alert($(this).attr('rel'));
    which shows the value
    3.Is a request sent for the test.php file? Yes as I've got
    Code:
    <div id="single-home-container"></div>
    this shows the value
    What do you mean it shows the value?
    Before or after the click?
    The way to check that the request is being sent is to investigate your apache log to find out when the request for that file occurs.

    Or you can use the Network section of a web development tool to look for the file request when you make the click.

    With Google Chrome you would use Ctrl+Shift+J and open the Network section before clicking.
    With Firefox+Firebug you would open up Firebug and enable the network section from your page before clicking.
    With Internet Explorer you would use F12 to open up the developer section and go to Networking, and start capturing before clicking.

    Is a request sent for the test.php file?

    What you need to see is something like this:

    Request URL:http://www.somedomain.com/test.php?locationID=3
    Request Method:GET
    Status Code:200 OK
    Now when the page loads either, but when you click on the link.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Member
    Join Date
    Dec 2007
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean it shows the value?
    Sorry! On loading the site, nothing is shown. If I click a link 1) I get a pop up with a value e.g. 9. Then on the page where the
    Code:
    <div id="single-home-container"></div>
    would be I see 9

    If I use Chrome and do ctrl=shift=j I see this:
    http://localhost/domain/test.php Failed to load resource: the server responded with a status of 404 (Not Found)

    So guess it's not working as I though

    If I change the path in the header script to a path of footer.php I get this error:
    Fatal error: Call to undefined function query_posts()
    If I remove
    Code:
    <div id="single-home-container"></div>
    the error goes but I dont see anything like
    Request URL:http://www.somedomain.com/test.php?locationID=3
    Request Method:GET
    Status Code:200 OK

  6. #31
    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)
    Quote Originally Posted by jarv01980 View Post
    Sorry! On loading the site, nothing is shown. If I click a link 1) I get a pop up with a value e.g. 9. Then on the page where the
    Code:
    <div id="single-home-container"></div>
    would be I see 9

    If I use Chrome and do ctrl=shift=j I see this:
    http://localhost/domain/test.php Failed to load resource: the server responded with a status of 404 (Not Found)

    So guess it's not working as I though
    That seems to indicate that the test file cannot be accessed.

    Quote Originally Posted by jarv01980 View Post
    If I change the path in the header script to a path of footer.php I get this error:
    [indent]Fatal error: Call to undefined function query_posts()
    That seems to confirm that it can at least access a file from your localhost

    Quote Originally Posted by jarv01980 View Post
    If I remove
    Code:
    <div id="single-home-container"></div>
    the error goes but I dont see anything like
    If the container doesn't exist, jQuery won't be able to run the .load method

    So you need to figure out why your local testing environment can't access that test.php file.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

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
  •