jeudi 25 avril 2019

How to pass data in $ .post ajax with php

Good morning people. I'm new to PHP and need a help with an api implementation.

I need to pass the ajax.post the client data, email and password. When I step directly in php it works perfectly. But when I send via data, it returns 500 from the server.

An example:

public function createUser(){
    $this->post("api/license-manager/users", [
        "email" => "xxxxxxxx@hotmail.com",
        "name" => "xxxx 232r4 xx"
    ]);
    return $this->result();
}

I wish it would work this way:

var data = {
    'email': "xxxxx@test.com",
    'name': "Xxxxxx 001323"
}
$.ajax({
  type: "POST",
  url: '/midleware/createuser/',
  data: JSON.stringify(data),
  success: function(data){
        console.log(data)
  }
});

Can someone help me?



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2ZJ8Czg
via IFTTT

Aucun commentaire:

Enregistrer un commentaire