相关文章推荐
眉毛粗的油条  ·  jQuery键盘事件详解·  1 月前    · 
踏实的墨镜  ·  * 和 ?在 shell ...·  11 月前    · 
悲伤的冰棍  ·  vue-router ...·  2 年前    · 
玩足球的手术刀  ·  Angular 6 - HTTP ...·  2 年前    · 
深沉的黑框眼镜  ·  c# - ...·  2 年前    · 
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Im using html5 capacities to read image width and height before submitting... Well, this is not happening exactly, it seems like the time needed for the functions:

reader.readAsDataURL(); 
reader.onload = function();
image.onload = function();

To read the file is way too much than the time my form is able to wait before sending the pic. I can check that the beforeSubmit function is triggered, but the form is submitted before it finishes.
Another weird thing is that I have replaced the beforeSubmit function content with a simple return false sentence and the form is being submitted anyway.
Am I missing something regarding the beforeSubmit option in ajaxSubmit?

The beforeSubmit function has been minimized to a return false statement, here comes the submit (the form is inside a dialog(), may be this the clue?:

$('.block .imgpop').on("click",function()
    type = $(this).attr('emimage');
    currentype = type;
    options = 
        type: 'POST',
        target:   '#uploadverbose',
        beforeSend:  beforeSubmit,
        resetForm: true,
        success: showResponse,
        data: { type: $(this).attr('emimage'), tempname: $(this).attr('id'), maxsize: imgsizesW[$(this).attr('emimage')] },
        dataType : "text"
    $('#uploadbitch').dialog(
        closeOnEscape: true,
        width: 800,
        modal: true 
    return false;
$(document).on("click","#MyUploadForm input[type=submit]", function(e, submit)
        if (!submit) e.preventDefault();
        $('#MyUploadForm').ajaxSubmit(options);                                 
                If I substitute the "click" for the "submit" when I click on the submit button it not only fires immediately, but it also opens the php page.
– user997593
                Mar 4, 2014 at 17:55
                To be more accurate: I made a mistake and I didn't copied everything you wrote, with your exact code, it works exactly as before: the beforeSubmit is triggered but it doesn't prevent the form to be submitted.
– user997593
                Mar 4, 2014 at 17:59
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.