I want when the result is 1 DIV showed
my php code
if($FileType != "zip" && $FileType != "ZIP") {
echo '1';
}
my html form code
<form id="my-form" method="post" enctype="multipart/form-data">
<textarea id="_text" name="text" required=""></textarea>
<input id="_from" name="from" type="hidden" value="<?php echo $id; ?>"/>
<input name="to" type="hidden" value="<?php echo $touser; ?>"/>
<input name="post" type="hidden" value="<?php echo $postid ?>" />
<div class="file">
<li>ملفات .zip فقط</li>
<input class="up" type="file" name="up" />
</div>
<button class="submit">submit</button>
</form>
my javascript code
<script>
$( '#my-form' )
.submit( function( e ) {
$.ajax({
url: 'chat_a.php',
type: 'POST',
data: new FormData( this ),
processData: false,
contentType: false
} );
e.preventDefault();
document.getElementById("my-form").reset();
});
</script>
I want when the result is 1 DIV showed
Add a success handler:
$.ajax({
url: 'chat_a.php',
type: 'POST',
data: new FormData( this ),
processData: false,
contentType: false,
success:function(response){
if(response == "1")
{
// DO YOUR STUFF
}
}
} );
UPDATE:
add the comma after contentType: false.
I have already done that in the answer.
You need to add a success or done function (depending on the version of jQuery). For the latest versions you would use done:
$.ajax({
url: 'chat_a.php',
type: 'POST',
data: new FormData( this ),
processData: false,
contentType: false
})
.done(function( msg ) {
if(msg == '1') {
// your code here
}
});
From the docs -
Deprecation Notice: The
jqXHR.success(),jqXHR.error(), andjqXHR.complete()callbacks are removed as of jQuery 3.0. You can usejqXHR.done(),jqXHR.fail(), andjqXHR.always()instead.