event.preventDefault()提交表单

I am using cakephp and jquery with the form (file-field with submit button) to upload picture.

All I need to do is to do AJAX image upload form. I don't want to refresh the page. So I bind event.preventDefault on submit the form. But I am not sure that the $_FILE['y'] is stopped by the event.preventDefault.

I wonder if the form is submitted ,and I bind event.preventDefault on submit the form.

Do the superglobal,such as $_REQUEST['x'] , $_FILE['y'] ,$_POST['x'] ,$_GET['x'] still there?

if not there , how to do this?

thankyou.

<script type="text/javascript">
$(document).ready(function() {

 var getAjax=function(event){

  $.ajax({

        'url':'<?php echo $this->webroot;?>vehiclePictures/addImageAjax/',
        'data': {'x': 33,'y':44},
        'dataType': 'json',
        'type': 'GET',
        'success': function(data) {
         if (data.length) {
          $.each(data, function(index, term) {
       alert(term[1]);
          });
         }
        }
  })
  event.preventDefault();
 };

 $('#imageUploadForm').submit(getAjax);

});
</script>

If you're using a button to submit the form, I'd just add return false to the button and have it run the ajax-call instead. Not sure if this is what you were wondering tho?

Like this:

<form method="post" action="someFile.php">
    //Form here
    <input type="submit" id="buttonToPostForm" />
</form>

function ajaxCall() {
    $.ajax({
       //Ajax data goes here
    });
}

$("#buttonToPostForm").click(function() {
    ajaxCall();
    return false;
});

And fill in so the data from the form is sent like in you original code.

Hope I understood the question correctly, if not I apologize:)