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
https://forums.phpfreaks.com/topic/115025-implementing-ajax-with-url-data/
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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.