0
I once again here. Come on.
Well, here’s my problem:
I am passing values to my method in php via ajax, however they are not returning me anything, I did some tests and it is catching on the following line
I will post the test code (where it gives me back) and what I want but is crashing
PHP method
public function listarCidade($id)
{
$obj_cidade = $this->verTodos("est_id=$id");
if( $obj_cidade )
{
$opt="";
foreach ($obj_cidade as $key)
$opt .= "<option value='{$key->id}'>{$key->cid_nome}</option>";
echo json_encode($opt);
}
}
In this line:
$opt .= "<option value='{$key->id}'>{$key->cid_nome}</option>";
-O problema está sendo apenas isso ( `$key->cid_nome` )
because if I remove this little code it gives me the return but without anything written in
<option></option>
What to do in people ?
json
is to return array, your code is creating astring
, so just giveecho $opt
and should work. Now if you’re retouching something else, you have to post the ajax request code and also the html page data that it’s picking up.– Leonardo
HAHAHAHAHHA, solved friend!
– Pedro Soares
I changed my return to html, for being a simple string the return, I did not know that had this conflict because it always works like this. I will pay more attention, an experience more acquired today. THANK YOU!
– Pedro Soares
@LVCS can add an answer?
– Sergio
Thanks for the kembrar, I’ll post!
– Leonardo