Jump to content

Implementing AJAX with URL data


peuge

Recommended Posts

Wassup all,

 

So im completely new to AJAX but am really keen to get started! I have been reading forums, tutorials etc... I have the following question:

 

echo '<a class="menuhref" href="index.php?choice=3&&category=' . $url . '" target="_parent">' . $i . '</a>';

 

All the tutorials I have been reading are about passing form data, is it possible to pass url data like above using AJAX?

 

Thanks in adavance!!!

 

Link to comment
Share on other sites

Yes, but not in that way.

 

You want that link to call a function, not be a link.  From your function you would add the necessary params to the url (choice=, category=) etc.

Since that is a $_GET query, it's relatively easy, and your tutorials should show you how.  But remember, AJAX performs stuff in the background and returns results, rather than actively moving the user to a new page, as your <a> tag currently does.

 

<?php
  echo '<a class="menuhref" href="#" onclick="someFunction(\'3\',\''.$url.'\')">'.$i.'</a>';
?>

That would pass 2 arguments to someFunction which could then do what you wanted and send back to results (for you to place appropriately with javascript)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.