Input Hidden receive $.ajax array

Asked

Viewed 84 times

0

I have a $.ajax who receives from PHP

json_encode( array ($html, $relatoriosGr) );

That one Return of $.ajax, will popular a input Hidden with the index 1 of result:

success: function (result) {

                $("#dados").val(result[1]);

}

This occurs automatically. But there’s a problem: it’s empty

How to solve this problem?

json_encode( array ($html, $relatoriosGr) );

Doesn’t change so much $html how much $reporters in a string jQuery?

So why php input is complaining?

I tried to make

echo array ( json_encode( $html), json_encode( $relatoriosGr) );

But gives the following error:

<b>Notice</b>:  Array to string conversion in <b>D:\Trabalhos\host\htdocs\wesleyanagceu.com.br\_scripts\_php\_buscas\relatorioCelulas.php</b> on line <b>80</b><br />
Array

inserir a descrição da imagem aqui

Goal:

In the anaixo piece of code:

<input type='hidden' id='dados' />
<button id='btnRelatorio' class='button'>Gerar Relatório</button>
<div class='dialog'></div>

Populo the input Hidden with the trace of $.ajax and make available its value to the click of button btnRelatorio to another $.ajax

  • then, if so: json_encode( array ($html, $reportersGr) );, gives an Alert with empty value. If so echo array ( json_encode( $html), json_encode( $reportariosGr) );, gives <b>Notice</b>: Array to string Conversion in <b>D: Host jobs htdocs wesleyanagceu.com.br_scripts_php_report searchCelulas.php</b> on line <b>80</b><br /> Array

  • Ué. but this is how it is in the question. jsom’s Indice 1 is empty

  • added at the end of the question

  • <input type='Hidden' id='data' /> is because I will use its value in a $.ajax

1 answer

1


Cannot echo on Arrays, echo command is only for Strings.

Try with var_dump() or print_r()

Browser other questions tagged

You are not signed in. Login or sign up in order to post.