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 8938293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:35:31+00:00 2026-06-15T10:35:31+00:00

Basically I have a href that passes through the id of an image via

  • 0

Basically I have a href that passes through the id of an image via json which looks like this:

http://localhost:4567/public/vote.html?image=50b4d006fa4634bb130000fe

this then creates/updates an image in mongo based on the id and updates if the user/visitor has voted.

at the moment i use silex to redirect after the code within that vote.html has been processed:

 return $app->redirect('popular.html'); 

i was wondering if it was possible to use jquery to process the above href without redirecting, so basically i could click vote and the number would change seamlessly without the user knowing they have been redirected.

answered

sorry for the vague question but my answer does come from the principle of that posted below.

i changed the href to assign a class of vote & the id of the image:

<a class="vote" id="' + image.id + '" href="#">

then added this to my $(document).ready function:

$(".vote").live('click', function() {
        $('span', this).toggle();
        $.ajax( site_url + 'vote.html?image=' + $(this).attr('id'));
    });

this in theory uses the id of the mongo object and appends it to the url for each time the object is clicked, processing the href without redirecting.

  • 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-06-15T10:35:32+00:00Added an answer on June 15, 2026 at 10:35 am

    Yes, you can use a bit of jQuery to help you out. This is a very contrived example, as you have not provided any HTML markup examples for your vote buttons / images.

    $(function() { // anything in here will happen once the DOM is ready
        $('.vote').click(function(e) { // assign click for each elem w/ class "vote" 
            e.preventDefault(); // prevent default action (if elem was an anchor)
            // Make the server request asynchronously
            var $this = this;
            $.ajax({
                type: "POST", // or "GET"; or use $.post()/$.get() 
                url: $(this).attr("href"), // the href of the anchor
                data: null // or JSON here (e.g. { 'id': 'abcde' })
            }).done(function(data) { // vote.html should be image data of some kind
                // update the DOM with the new vote image
                // possible example if response was base64 encoded png
                $($this).closest('image').attr("src", "data:image/png;base64," + data);
            });
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have a gridview that I page through the server instead of in
I basically have a program that filters records from one excel file to another
I basically have three tables, posts, images and postimages (this simply contains the ids
I basically have 7 select statements that I need to have the results output
I basically have the same question as this guy .. The example in the
I have to the following function that I would like to modify so that
I have this wordpress blog that has many pages with subpages that dropdown on
We have an About our app popover that is html formatted and basically a
I'm trying to figure out how to make this code work. Basically i have
Sorry for this question. Basically I have a page where I have it automatically

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.