1

I created a json with this structure

var data = 
{ 
    "people": [ 
      { "name" : "John", "id" : 1 },
      { "name" : "Marc", "id" : 2 }
     ] 
}

Now here's how i send the data to the php

var ordenDeCompra = JSON.stringify(data);
$.post("../Backend/ordenesDeCompra.php",
    {
        ventas: data, 
        idcliente : $('#sltCliente').val(),
        subtotal: subtotalfactura
    },
respuesta);

Now when i tried to handle the data in the php it doesn't have any values, i know that the values are sending well, because i see the data sending with charles debugging proxy.

This is how i tried the get the value in the php

$array = json_decode(stripslashes($_POST['ventas']), true);

Am i sending the values corrected??

0

3 Answers 3

2

change

ventas: data, 

to

ventas: ordenDeCompra, 
Sign up to request clarification or add additional context in comments.

Comments

1

Use:

var ordenDeCompra = JSON.stringify(data);
$.post("../Backend/ordenesDeCompra.php",
    {
        ventas: ordenDeCompra, 
        idcliente : $('#sltCliente').val(),
        subtotal: subtotalfactura
    },
respuesta);

Comments

0
var ordenDeCompra = JSON.stringify(data);
$.post("../Backend/ordenesDeCompra.php",
    {
        ventas: ordenDeCompra, // shouldn't it be ordenDeCompra than data
        idcliente : $('#sltCliente').val(),
        subtotal: subtotalfactura
    },
respuesta);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.