Uncaught Error: Attempt to assign property "id" on null

Viewed 26

I am sending two post variables through ajax but when I receive them I get this error

Uncaught Error: Attempt to assign property "id" on null in /Applications/XAMPP/xamppfiles/htdocs/ecommerce_cursos/backend/ajax/slide.ajax.php:90

let itemSlide = $(".itemSlide");

$('.todo-list').sortable({

    placeholder: 'sort-highlight',
    handle: '.handle',
    forcePlaceholderSize: true,
    zIndex: 999999,
    stop: function(e){

        for(let i = 0; i < itemSlide.length; i++){
            
            const datos = new FormData();
            datos.append("idSlide", e.target.children[i].id);
            datos.append("orden", (i+1));

            $.ajax({

            url: "ajax/slide.ajax.php",
            method: "POST",
            data: datos,
            cache: false,
            contentType: false,
            processData: false,
            success: function(respuesta){
            console.log(respuesta);
            if(respuesta == "ok"){

                console.log(respuesta);
        
            }

        }

    });

        }
        
    }

});

here I receive the variables and I get the error how can I solve this i am using php8

if(isset($_POST["idSlide"])){ 
    $oredenSlide = new AjaxSlide();     
    $ordenSlide->id = $_POST["idSlide"];    
    $ordenSlide->orden = $_POST["orden"];   
    $ordenSlide->ajaxOrdenSlide();  
}
0 Answers
Related