Simple jquery passing a parameter via a link

Hi all,
im new to jquery.

I have this window that opens a modal:

How can I I pass a variable to the page that is opened from the link, so for example it opens ajax.html?id=[variable]

in normal js I would have just included it in the function call, like openmodal(12), but not sure how to do it in jquery

Stephen ForlanceAsked:
Who is Participating?
To the link add something like this


In the jquery use

$.get('ajax.html?id='+$(this).data("id"), function(data){
You can add it directly in the js

$.get('ajax.html?id=somevar', function(data){

...unless there is more to it...?
Stephen ForlanceAuthor Commented:
Hi Gary, but how do I set somevar within the link?
Just change somevar to whatever it should be.
Stephen ForlanceAuthor Commented:
I think I need to explain what Im trying to do.

On the HTML there would be multiple links, each with a different variable.
Normally in JS I would do something like

<a href=#" onclick="somefunction(12)">a</a>

So the function somefunction would receive the variable 12, which I could then use to call the correct page.

How can I do this with jquery?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.