insert data with ajax and switch in php [closed]

-4

I have a php script that I use GET to get a url parameter and switch to a switch php and run a particular function.

This script works perfectly without any errors but how to use it with ajax ??

When I call ajax with url

url : cor.php , (in this case I would call the php file with switch ) it displays error and does not proceed, it does not find the switch function

Can anyone help me with this?

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;

    }}
    ?>
    
asked by anonymous 22.02.2017 / 05:02

1 answer

1
$.ajax({
url:'cor.php', data : {acao:'inserir'}, dataType : 'GET'
})
.done(function (retorno) {
//
});

In this case the action is as the variable is written in the PhP code.

    
22.02.2017 / 11:56