An building a jquery mobile which contains a file upload page. its a multiple template app. When a user uploads a file i want the user to be redirected to a new page without refreshing the div. With my current script when the upload is done the address bar refreshes. I used event.preventDefault();
which i taught could stop the page from refreshing after sending the data but still does refresh
<script language="javascript">
$(document).ready(function(){
$("#form1").on('submit',function(event){
event.preventDefault();
$.ajax({
url: "upload.php", // Url to which the request is send
type: "POST", // Type of request to be send, called as method
data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
contentType: false, // The content type used when sending data to the server.
cache: false, // To unable request pages to be cached
processData:false, // To send DOMDocument or non processed data file it is set to false
success: function(data) {
$('#msg').html(data);
var result = $.trim(data);
if(result==="OK"){
$.mobile.changePage("#page2");
}
}
});
});
});
</script>