Ajax photo uploader only works when I add debugger;

Ajax photo uploader only works when I add debugger;

when I step through the debugger in Chrome browser, my image actually uploads and inserts into the database otherwise it doesn't seem to get into the  saveDesign.php

Please help?
  1. $("#sub").click( function(){
    debugger;
    var canvas = document.getElementById('canvas');

    //var context = canvas.getContext("experimental-webgl", {preserveDrawingBuffer: true});
    var dataURL = canvas.toDataURL({format: 'png' });

    document.getElementById("canvas").src = dataURL;
    $.ajax({
    type: "POST",
    url: "saveDesign.php",
    data: { img: dataURL, adname:$('#adname').val(),user_id:$('#user_id').val(),templatesize:$('#templatesize').val() }
    // window.location.href = "http://www.jbiddulph.com/adbuild/checkout.php?adname="+adname+"&file="+dataURL+"&user_id="+user_id+"&templatesize="+$templatesize+"";
    }).done(function(msg){
    alert(msg);

    });


    });