M having problem with getting resposnse from the server.M using Jquery Ajax I want to upload a file using ajax.But the follwing lines of codes are not working page1:
<script language="javascript" src="jquery-1.7.1.js"/></script>
<script language="javascript" src="jquery.form.js"/></script>
<script language="javascript">
$(document).ready(function(){
$('#photoimg').change(function(){
var fd=new FormData();
$.ajax({
type:'POST',
url:'NewuploadScript.php',
data:fd,
contentType: 'application/x-www-form-urlencoded',
async:true,
cache:false,
processData: true,
success:function Result(data2) {
document.write(data2);
}
});
});
});
</script>
<form>
<input type="file" id="photoimg" name="file" multiple>
<input type="submit" id="BtnSbmt" value="Upload"/>
</form>
Pag2:
<?php
echo $name= basename($_FILES['photoimg']['name']);
echo $size= basename($_FILES['photoimg']['size']);
?>
when I run the codes jquery display the following error:
Uncaught TypeError: Illegal invocation
jQuery.extend.param.addjquery-1.7.1.js:7601
buildParamsjquery-1.7.1.js:7658
jQuery.extend.paramjquery-1.7.1.js:7621
jQuery.extend.ajaxjquery-1.7.1.js:7467
(anonymous function)ImageUploader.php:18
jQuery.event.dispatchjquery-1.7.1.js:3256
jQuery.event.add.elemData.handle.eventHandlejquery-1.7.1.js:2875