I make a lot of assumptions here due to the lack of information in the question.
Most likely your form looks something like this:
<form> <input type="text" name="lon" /> <input type="text" name="lat" /> <input type="text" name="heading" /> <input type="file" name="image" /> <input type="button" id="submit" value="Submit" /> </form>
Immediately there is a problem with entering the file. Files cannot be sent via ajax using jQuery ajax methods without including additional plugins that correctly process it behind the scenes or write your code, instead send a hidden iframe or some other method (html5? Flash?).
Ignoring file input here is where your original problem is.
$("#submit").click(function(){ $.ajax(...); });
I did not use ajax options because they do not matter. The problem is that since the button in your form is the last on the form and there is no submit button, it will act like the submit button and submit the form if you do not prevent this action by default. If you do not prevent this action by default, the form will be submitted with the default type "GET", since you did not specify the type in your form.
To prevent the default action of the click event, either return false or use event.preventDefault()
$("#submit").click(function(event){ event.preventDefault(); $.ajax(...); });
Resolving file input problems probably already answered a few other SO questions.
source share