Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-21-2010, 04:51 PM   PM User | #1
php_guest
New Coder

 
Join Date: Jun 2009
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
php_guest is an unknown quantity at this point
jquery ajax with get

I have the following function:
Code:
...
      $.ajax({
        type: "POST",
        url: showresults.php,
        data: "clickedPage=" + clickedPage + "&id=" + id, 
        error: function(){        
            alert('Error loading XML document');                    
        },
        success: function(msg){                        
        //put results received from ajax call to div                      
        }
      });  
...
Then I have in showresults.php lines
Code:
if(!empty($_POST[clickedPage])){
    $clickedPage=$_POST[clickedPage];
  }

Everything is fine, but I don't know how I can use this with GET. I tried to replace type: "POST", with type: "GET", and then if(!empty($_GET[clickedPage])){... but it doesn't work.

What would be the correct syntax in function to get in showresults.php data with GET?

Thanks a lot
php_guest is offline   Reply With Quote
Old 06-21-2010, 06:50 PM   PM User | #2
Fumigator
UE Antagonizer


 
Fumigator's Avatar
 
Join Date: Dec 2005
Location: Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
Posts: 7,686
Thanks: 42
Thanked 637 Times in 625 Posts
Fumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of lightFumigator is a glorious beacon of light
I wouldn't do data: "clickedPage=" + clickedPage + "&id=" + id,
, I would do

PHP Code:
data: {"clickedPage" clickedPage"id" id
Also if I may nitpick for a moment, you should be enclosing your array index names in quotes, it's bad form to not.

PHP Code:
if(!empty($_GET['clickedPage'])){
    
$clickedPage=$_GET['clickedPage'];
  } 
__________________
Fumigator is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:25 AM.


Advertisement
Log in to turn off these ads.