0
I have a code that changes the value in the bank from 0 to 1 or vice versa, in 80% of cases it manages to make the change but sometimes gives this error Uncaught SyntaxError: missing ) after argument list
and I’ve tried to see the bank part and found nothing wrong
JS
function enviaAssociado(CTITULAR) {
if(CTITULAR){
$("#CTITULAR").remove();
$.ajax({
url: 'php_action/enviaAssociado.php',
type: 'post',
data: {CTITULAR : CTITULAR},
dataType: 'json',
success:function(response) {
manageTable.ajax.reload();
//$("#CTITULAR").val(response.CTITULAR);
}
});
}
manageTable.ajax.reload();
}
PHP
<?php
require_once 'db_connect.php';
if($_POST) {
$CTITULAR = $_POST['CTITULAR'];
$sql = " UPDATE importsmiles4e.tb_conv
SET STAT = CASE
WHEN STAT = 1 THEN 0
WHEN STAT = 0 THEN 1
ELSE STAT
END
WHERE substring(CTITULAR,2,6) = '$CTITULAR'";
$query = $connect->query($sql);
$CTITULAR = $_POST['CTITULAR'];
$sql = " UPDATE importsmiles4e.tb_conv3
SET STAT = CASE
WHEN STAT = 1 THEN 0
WHEN STAT = 0 THEN 1
ELSE STAT
END
WHERE substring(CTITULAR,2,6) = '$CTITULAR'";
$query = $connect->query($sql);
$connect->close();
}
?>
Would you kindly pass all the error that is generated in the IDE’s Tracktrace?
– user148754
In the IDE everything is normal, so much so that in most cases it works. I only have what the Chrome console accuses when it error.
– MarcoFalcao
@Marcospalcao this seeing of the written right side
index.php:1
, click there and you will be taken straight to the code and the line of error, and inform me.– user148754
Where are you returning JSON in PHP? Your PHP code shows nothing.
– Sam
Did you check the value of CTITULAR when the error occurs? There will be some parser problem?
– GustavoAdolfo
The value returned when the error is the same as when it does not, the format in the case.
– MarcoFalcao
@Sam Sorry I didn’t inform you.
– MarcoFalcao
You’re confused about this. What does index.php have to do with the problem? In your Ajax you’re calling the
enviaAssociado.php
and is expecting a JSON withdataType: 'json',
, that is, the fileenviaAssociado.php
is thank you to return a JSON, otherwise it will not even enter thesuccess
. Only in the PHP code you put in the question (I imagine that is theenviaAssociado.php
) is not returning anything, just doing operations in the database. But what is unclear is where the index.php goes into this to error it..– Sam
i posted what Send returns but got bugged, and only left the index print, https://i.stack.Imgur.com/Mhsdh.png and when it works it always returns something in the same format.
– MarcoFalcao
Show the code referring to the image, as you are calling the function.
– Sam
@Sam https://i.stack.Imgur.com/LMXP0.png
– MarcoFalcao