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

115
Views
Enviar un texto estático en ajax

Estoy haciendo una pagina de recarga de imagen

 <button id="ref_qo" class="button_ref"><a href="#" style="text-decoration: none !important;">Reload question</a></button>

Pero esto no se hace correctamente.

 <script type="text/javascript"> $(document).ready(function() { $('#ref_qo').click(function(e) { e.preventDefault(); $.ajax({ type: "GET", url: 'image_lod.php', data: { id: 'image_url', IdCompanyAnbar: '12'}, success: function(response){ var resp = JSON.parse(response); if (resp.success == "0"){ alert(resp.message) } else { alert(resp.message); } } }); }); }); </script>

y da el siguiente error

Error de sintaxis no detectado: token inesperado < en JSON en la posición 0 en JSON.parse () en Object.success ((index):334:24) en i (jquery.min.js:2:28017) en Object.fireWith [como resolveWith ] (jquery.min.js:2:28783) en A (jquery.min.js:4:14035) en XMLHttpRequest. (jquery.min.js:4:16323)

No creo que haya problema con el servidor.

 <?php if (isset($_GET['image_url']) { $url = $_GET['image_url']; // Save all user data if($url == 12){ echo json_encode(array('success' => 0, 'message' => 'Please complete both fields')); } else { echo json_encode(array('success' => 1)); } } ?>

¡Gracias de antemano por su ayuda!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

el problema: en esta condición if (isset($_GET['image_url']) {....

1: no enviaste image_url al servidor.

2: y falta el ) en la condición if.

Puede modificar el código en el servidor de la siguiente manera

 <?php if (isset($_GET['id']) && $_GET['id']=='image_url') { $url = $_GET['IdCompanyAnbar']??0; // Save all user data if($url == 12){ echo json_encode(array('success' => 0, 'message' => 'Please complete both fields')); } else { echo json_encode(array('success' => 1)); } }else{ echo json_encode(array('success' => 1)); } ?>
about 4 years ago · Juan Pablo Isaza 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!