-4
I have a php script that I use GET to take a parameter from url and move on to a php switch and perform a certain function.
That one script works perfectly without errors but how to use it with ajax??
When I call the ajax with the url
url: cor.php
, (file without switch) it records the data perfectly but when the ajax flame
url: cor.php?acao=inserir
, (in this case, I would call the php file with switch) it shows error and does not proceed, it does not find the switch function
Can someone help me with that?
Switch structure:
<?php
session_start();
if (empty($_SESSION['id_usuario'])){
echo "Acesso negado!";
exit;
}else{
include "conexao.php";
$id = (int)$_GET["id"];
$acao = $_GET['acao'];
switch ($acao) {
case alterar:
break;
case excluir:
break;
case bloquear:
case ativar:
break;
case cadastroCor:
break;
}}
?>
If you’re talking about switch of PHP, you’d better edit that question and show the script error.
– ShutUpMagda
Please, we need the code to help you - or at least part of it.
– Cesar Augusto
friends , if you know what ajax and switch is in php, the code is not necessary, so you must know how to make the ajax call a switch function from the php file and pass the data to it
– Jonnys J.
Without the correct posting of your code, it is difficult to help you, the switch case you posted for example is treating the strings incorrectly, for example. Post php code and your view to be parsed.
– Paulo Santos