ajax returning white

0

I once again here. Let's go.

Well, my problem is this:

I am passing values to my method in php via ajax, but they are not returning anything to me, I did some testing and it is working on the next line

I'm going to post the test code (where it returns me) and what I want, however, is catching

  

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 with nothing written in

<option></option>

What to do in galera?

    
asked by anonymous 16.04.2016 / 00:58

1 answer

0

json is to return array, your code is creating a string, so just give echo $ opt and it should work.

Now if you are retuning something else, you have to post the ajax request code and also the data of the html page that it is catching.

    
18.04.2016 / 04:10