Parameter passing in URL using JSON + AJAX

0

I'm studying JavaScript and would like support from you.

I have a file that I called getPagamentosMaioresQue.php , this file has the following syntax:

<!DOCTYPE html>
<html>
    <head>
    	<title> PHP Trabalhando com Arrays</title>
        <meta charset="utf-8">
    </head>

    <body>
        <?php require_once("Pagamentos.class.php");

            $valorPagamento = $_GET['valor'];

            $objPagamentos = new Pagamentos();
            $objPagamentos->pesquisaPagamentosMaioresQue($valorPagamento);

        ?>
    </body>

</html>

... and I have another file called grafico.php where I call the above file using that part of the code ...

function desenhaGraficoPagamentos(){
                var jsonData = $.ajax({
                    url: "getPagamentosMaioresQue.php",
                    dataType: "json",
                    async: false
                }).responseText;

It turns out that when I use getPagamentosMaioresQue.php?valor=10 it works normally ....

I want to know how to pass these parameters to this file through grafico.php?valor=10 ?

    
asked by anonymous 26.08.2016 / 05:20

1 answer

0

function desenhaGraficoPagamentos(){
                var jsonData = $.ajax({
                    url: "getPagamentosMaioresQue.php",
                    dataType: "json",
                    async: false,
                    data: valor, 
                }).responseText;

add the date property in $ .ajax Where this variable (value) added as parameter in your $ .ajax would be value received by your grafico.php file

    
26.08.2016 / 06:18