Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6580607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:02:59+00:00 2026-05-25T16:02:59+00:00

I have links like http://example.com?query1=query1&query2=query2 as href of anchor tag. I want to do

  • 0

I have links like
http://example.com?query1=query1&query2=query2 as href of anchor tag.
I want to do post ajax on href click using data from the query parameter from the link.
I have written code

$("a").bind('click',function(){
    $.ajax({type:'post',url:$(this).attr('href'), success: function(data){
    alert(data);
  }})
        return false;
});

but it does not send query parameter inside ajax post request. Request query data length is 0.

how can I change this code to manipulate data from query parameter of link ?

Edit

Sorry my bad but it is not working these are the request

Accept:application/json, text/javascript, */*; q=0.01
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:0


Query String parameter 
action:delete
id:12

So these fields are not going inside request content.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T16:02:59+00:00Added an answer on May 25, 2026 at 4:02 pm

    You need to use the value of the href attribute, not just the jQuery object itself.

    url:$(this).attr(‘href’).val()

    Update

    Although you said this answer worked for you, I made a mistake. val is not a valid function of attr however doing it the original way you had it works for me.

    See this demo: http://jsfiddle.net/PuyzU/

    Update 2

    Ok, I see your problem now. It wasn’t atall clear from the question what you meant.

    Let me rewrite your question here to make sure I’m on the right track.

    I want to take the querstring parameters of a URL and use them in my ajax
    POST action. How do I do that with jQuery?

    In your ajax post method there is a property data where you’ll store the data you want to post to the server.

    $.ajax({
        type: 'post',
        url: "http://[...],
        data: DataToPostToServerHere
        [...]
    

    In this case we can obtain the querysting parameter values as a single string by splitting our URL on the ? and use the first portion of the array as the URL and the second portion as the data we’re sending:

    var urlFull = $('#myLink').attr('href').split('?');
    urlFull[0] // Our URL
    urlFull[1] // The data to put into the data property for posting.
    

    Working Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

in my website I have links like this - http://example.com/index.php?page=about and I want to
I have links like these that I want to change: mypage.com?page=missions&id=5 mypage.com?page=hello I tried
i have this bit of code: <?php $file = file_get_contents('http://example.com'); preg_match_all(/<a href=(.*?links.*?)>.*?<\/a>/i, $file, $a);
I have the following links: <a href=http://example.com/src/abc.png><img src=http://example.com/res/bca.png></a> <a href=http://example.com/src/hvc.gif><img src=http://example.com/res/ncq.jpg></a> Using PHP, I
I'm creating pagging for some data. For example, I have a page: http://example.com/news.php?type=bla&smth=bla There
This is a nasty one. I have an external link. <a href=http://www.example.com target=_blank> now
i have multiple strings containing a link like: <A HREF=http://www.testings2>testings2</A> <A HREF=http://www.blabla>blabla</A> <A HREF=http://www.gowick>gowick</A>
I have an anchor tag which i want to use to go to a
Let's say I have a URL: http://example.com/person/list This website will display a list of
I have an existing journal website with the following url structure http://example.com/dbtable_id/ (eg. http://example.com/89348/)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.