-1
Hello guys I hope you can help me, I’ve been having this problem for a long time
I pass my data via Ajax to my class but in the URL do not know how to reach it in a way other than error
I tried it this way
$.ajax({
type:'post',
url:'Classes/Usuario.class.php',
ajax:'1',
data:{id:1},
success: function (data){
alert(data)
}
});
Well, remarks if you help me answer.
It is Obviou that will give error kkkk, as said my other instance User class, extends another so I can not pass my values like this.
Another thing that may help, my classes are called automatically by the magic __autoload() method. I believe that in this way there is a different way to write the URL.
Good people, please do not indicate another post, if you do not understand tell us in the comments that are with you until we can solve this problem !
Thank you for helping me ! until..
As requested I am just below comes the code of the file Usuario.class.php
<?php
/**
* Created by PhpStorm.
* User: Pedro
* Date: 19/01/2016
* Time: 00:43
*/
class Usuario extends BancoPizza
{
public $Tabela = 'pizzaria';
public $Campos = array(
'nome_pizzaria',
'usuario_pizzaria',
'senha_pizzaria',
'rua_pizzaria',
'numero_pizzaria',
'bairro_pizzaria',
'cidade_pizzaria',
'uf_pizzaria',
'status_pizzaria'
);
/**
* @param $dados -> Campos da tabela
* @param $Campos -> A classe ja tem os campos da tabela
*/
public function verUm($where=null){
return parent::verUm($this->Tabela, $where);
}
public function verTodos($where=null, $ordem=null)
{
return parent::verTodos($this->Tabela, $where, $ordem);
}
public function excluir($where)
{
//Aqui eu queria pegar a Id do item clicado e através do ajax passar essa id, porem preciso saber como especificar o método que esse meu valor vai, correto ?
return $_POST['id'];
return parent::excluir($this->Tabela, $where);
}
public function editar($campoTabela, $valor, $id)
{
parent::editar($this->Tabela, $campoTabela, $valor, $id);
}
}
The class does not stop being a file so just take the post and pass the values to the object
– rray
post your User code.class.php. The above code should go to some method in the correct User class? Which one?
– Thomas Lima
@Thomaslima - dear you said a very impractical thing, specify the method my values go to, to top updated the code. It became clearer to help me ?
– Pedro Soares
@Pedrosoares apparently your only problem is lack of information for which method you want to send your data. Are you using MVC? Ideally you send your data to a control class, it will be responsible for instantiating your user class and calling the corresponding method.
– Thomas Lima
Do not send the post directly to the class file! Send it to another php page that includes the necessary classes, instates them and does all the necessary process.
– Pedro Erick
@Thomaslima I think I’m getting the idea, can you explain me how to call the method from the URL ?
– Pedro Soares
@Pedroerick - I’ll try this, but Thomas is right, I need to call the method besides calling the class and instating it. but I don’t know how I do it.
– Pedro Soares