Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
ajax si resultado = 1 mostrar mensaje en div

Quiero cuando el resultado es 1 DIV mostrado

mi codigo php

 if($FileType != "zip" && $FileType != "ZIP") { echo '1'; }

mi código de formulario html

 <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>

mi codigo javascript

 <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>

Quiero cuando el resultado es 1 DIV mostrado

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Agregue un controlador de éxito:

 $.ajax({ url: 'chat_a.php', type: 'POST', data: new FormData( this ), processData: false, contentType: false, success:function(response){ if(response == "1") { // DO YOUR STUFF } } } );

ACTUALIZAR: agregue la coma después de contentType: false .

Ya lo he hecho en la respuesta.

over 4 years ago · Santiago Trujillo Report

0

done agregar una función success o completa (según la versión de jQuery). Para las últimas versiones, usaría 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 } });

De los documentos -

Aviso de desaprobación: Las devoluciones de jqXHR.success() , jqXHR.error() y jqXHR.complete() se eliminan a partir de jQuery 3.0. Puede usar jqXHR.done() , jqXHR.fail() y jqXHR.always() en su lugar.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!