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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T21:15:05+00:00 2026-06-02T21:15:05+00:00

I am trying to use the jQuery $.post method to submit an ajax request

  • 0

I am trying to use the jQuery $.post method to submit an ajax request to a PHP script whenever a certain element is clicked. I don’t care about the value returned by the server – I just want to make sure that my data is submitted.

However, the element that receives the click could contain either a hyperlinked image or a flash element with several links in it. How can I ensure that my script receives the post request (again, I don’t care about its response) even if the user navigates away from the page? I am using the code below:

jQuery(document).ready(function($) {
    $(".click-track").mousedown(function(e) { // click() will not pass through a flash movie, so we must use mousedown
        ad_id = $(this).data("ad-id");
        var data = {
            action: 'log_click',
            adId: ad_id
        };
        $.ajaxSetup({async: false});
        $.post(myscript.php, data, function(data) {
            // Do nothing because we don't care about the response
        }, 'html');
    });
});

I’m no browser scripting guru, and this code has me flummoxed. I would appreciate any help you could give!

  • 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-02T21:15:09+00:00Added an answer on June 2, 2026 at 9:15 pm

    If you do an e.preventDefault() within the mousedown handler, you can simply do this inside the $.post call:

    $(".click-track").mousedown(function(e) { // click() will not pass through a flash movie, so we must use mousedown
        e.preventDefault();
        ad_id = $(this).data("ad-id");
        var data = {
            action: 'log_click',
            adId: ad_id
        };
        $.ajaxSetup({async: false});
        var jqxhr = $.post(myscript.php, data, function(data) {
            // Do nothing because we don't care about the response
    
        }, 'html');
        jqxhr.complete(function(){ $(this).trigger('click'); });
    });
    

    This should create an ajax object and attach a function when the POST request completes that should trigger a click on the originally mousedown’d element. I’ve gotten this to work with non-Flash elements, not sure if it will work on the Flash object, but it should.

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

Sidebar

Related Questions

I'm trying to use jquery.Ajax to post data to an ASP.NET MVC2 action method
So Im trying to use jquery's .post function to submit a form and return
I am trying to use the Post Method in my jquery code but it
Im trying to use jquery and ajax to submit a form and show the
I'm trying to use jquery to submit my form like so but it's not
I am trying to submit a form using jQuery's .ajax() function. It seems like
Hello I am a newbie working with jQuery and Ajax. I am trying submit
I'm trying to use the jQuery forms plugin to dynamically submit a form on
I'm trying to use the jQuery Autocomplete function to submit a form when an
I'm trying to use AJAX with jquery… this is what I'm trying to do

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.