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

  • Home
  • SEARCH
  • 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 8540353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:34:42+00:00 2026-06-11T11:34:42+00:00

Here’s the scenario – I have a page, within which there is a link

  • 0

Here’s the scenario – I have a page, within which there is a link to open a jQuery UI Dialog. Within the dialog is a small form (to upload an image). The ‘action’ page processes and returns the image, which is intended to be returned to the dialog.

Now, this all works as expected – however, it’s being processed twice for some reason. Visually, there’s nothing to show it’s being submitted and processed twice (I only know because I’m using Firebug, and I was trying to figure out why it was taking longer to process than anticipated).

Looking at previous answers here, the suggestion is that the jQuery code should be outside the dialog – but it already is. I’ve exhausted every avenue I can think of now. I’m new to JS/jQuery, so it’s entirely possible I’m missing something simple. Either way, pointers appreciated! My code below…

 <head[...]>
 <script>
 $(function() {
 $('#submitImage').bind('click', function(){
    $(".preview").html('');
    $(".preview").html('<img src="/images/elements/loaders/103.png" alt="Uploading...." style="text-align:center;"//>');
    $("#imgadd").ajaxForm({
    clearForm: 'true',
    target: '.preview'
    }).submit();
});
});
 </script>

[… rest of the page ….]

 <!-- Dialog -->

 <div id="customDialog" class="customDialog" title="Upload or Insert Image">

 <form id="imgadd" action="a_blogimgupload.cfm" method="post" enctype="multipart/form-data">
 <input type="file" class="fileInput" name="blogimg" />&nbsp;<input type="submit" id="submitImage" value="Upload" /></form>

 <div class="preview">
 <ul>
 <li><img src="imgthumb.png" alt="" /><a href="javascript:;" title="Insert" onclick="addImage('imgfull.png');return false;">Insert</a></li>
</ul> 
</div>
  • 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-11T11:34:43+00:00Added an answer on June 11, 2026 at 11:34 am

    You .ajaxForm is used to prepare form for being sent with ajax. One you use it – each submit of that form will be done with AJAX.
    So, you must move code below outside click

    $("#imgadd").ajaxForm({
        clearForm: 'true',
        target: '.preview'
        })
    

    (Also, you do not need .submit() call in click handler, as it already cause submit)
    Or, you may change your code like this:

    $('#submitImage').bind('click', function(e){
        $(".preview").html('');
        $(".preview").html('<img src="/images/elements/loaders/103.png" alt="Uploading...." style="text-align:center;"//>');
        $("#imgadd").ajaxForm({
        clearForm: 'true',
        target: '.preview'
        }).submit();
        e.preventDefault();
    });
    

    Where e.preventDefault() (well, never tried such thing, maybe you will need to do also e.stopPropagation(), but I do not think so) will stop browser from executing default action which is submit. But the best would be here to do the first thing.

    Also, there is .ajaxSubmit() which accept the same options as ajaxForm, but it also cause submit immediately. But if you will use it – you will need to remove .submit and e.preventDefault is still required.

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

Sidebar

Related Questions

Here the scenario is I have many .aspx pages if any page gives error,
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is my code (Say we have a single button on the page that
Here's a problem I ran into recently. I have attributes strings of the form
Here's my scenario - I have an SSIS job that depends on another prior
Here is my code, which takes two version identifiers in the form 1, 5,
Here is my scenario. I have a website running under AppPool1 and that works
Here are the tables I have: Table A which has entries with item and
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here is the scenario. I'm writing my geo-ruby oracle adapter for Ruby On Rails

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.