Welcome Guest, Not a member yet? Register   Sign In
error returning a view with $data from ajax
#1

I have got a error 500 when from a controller called from a ajax function if in the controller return a view with params.

the js/ajax call:

Code:
function insertFotosNew(url,id){
        var form = document.querySelector('#new-fotos-form');
        var fd = new FormData(form);
        var url_return = '<?=base_url('propiedad_edit/')?>/'+id;

        $.ajax({
            type: "POST",
            url: '<?=base_url('subir_fotos')?>',
            data: fd,
            contentType: false,
            processData: false,
            success: function (resultado) {
                console.log(resultado);
                $('#modal-new-foto').modal('hide');
                $('#productoForm').submit();

            },
            error: function (resultado) {
                alert('Se ha producido un error al conectar con el servidor.');
            }
        });
     }

the controller code:

PHP Code:
namespace App\Controllers\Administracion\Propiedades;

use 
App\Controllers\Repositories\ProductosFotosRepository;

class 
SubirFotos extends PropiedadesBaseController
{
    protected $response;
    protected $productosFotosRepository;

    /**
     * SubirFotos constructor.
     */
    public function __construct(){
        parent::__construct();
        $this->productosFotosRepository = new ProductosFotosRepository();

    }

    /**
     * @return View
     */
    public function run(){
        $todo       $this->request->getPost();
        $files      $this->request->getFiles();

        $data = array();

        if(count($files) > 0) {
            $this->respuesta $this->propiedadNewFotoUpload($todo['id_producto'], $files);
            $data['fotos'] =  $this->productosFotosRepository->getProductoFotos($todo['id_producto']);
        else  {
            $this->respuesta->mensaje 'No hay ficheros para subir';
            $this->respuesta->estado EXIT_ERROR;
        }

        echo view('Administracion/Propiedades/propiedades_form_fotos'$data);

    }



The same error if echo the view:
PHP Code:
echo  view('Administracion/Propiedades/propiedades_form_fotos'$data); 

If only echo (or return) the view without %data, no occurs the error 500.

This in CI3 not produces this error.

Can help?

Tanks
Reply
#2

** Close this, please. I found the problem. ***
Reply
#3

And the problem where? So others can learn from it. :-)
Reply




Theme © iAndrew 2016 - Forum software by © MyBB