0
I want to send a vector coming from javascript to PHP. I have the following code but it is not working. How to do?
info = [];
info[0] = 'thiago';
info[1] = 'carlos';
alert(info[0]);
$.ajax({
type: "GET",
data: {info:info},
url: "buscar.php",
success: function(msg){
console.log(msg);
}
});
Give a
var_dump($_GET)
in your php file and aconsole.log(msg)
in your javascript and put here the return;– Pedro Augusto
that was the return of the console. <pre class='Xdebug-var-dump' dir='Ltr'> <small>C: wamp64 www Projectjax2 Ex3 fetch.php:13:</small> <b>array</b> <i>(size=1)</i> 'info' <font color='#888a85'font>=></> <b>array</b> <i>(size=2)</i> 0 <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'Thiago'</font> <i>(length=6)</i> 1 <font color='#888a85'>=></font> <small>string</small> </font color='#cc0000'>'carlos'</> <i>(length=6)</i> </pre>
– thiago xavier
It was the return in Success?
– adventistaam
Try to recover this info variable like this:
$info = json_decode( $_GET['info'] )
– adventistaam
yes there was a return. However ,when I write an echo on the page where the data should be ,there is no return.
– thiago xavier
And as var_dump as the colleague suggested, what returns?
– adventistaam
returns nothing !
– thiago xavier