how to send parameters in D3.json to php

Asked

Viewed 68 times

2

good there is some way to send D3 parameters to make a request to php.

I have a search form that will send data to php in post form I wanted and return the result in json

d3.json("../querys/querys.php", function(error, graph) { 

1 answer

1

To D3 documentation refers only two arguments passed to the function:

d3.json(url[, callback])

That means you have to send the data on query string concatenated with the url, and the server has to interpret this.

var data = '?nome=joao&idade=45';
d3.json("../querys/querys.php" + data, function(error, graph) { 
  • Hello Cousin :) in this case if it has to POST, it cannot be with querystring in the URL, the data in an HTTP POST is sent in the body, not in the URL. and in this case, using D3, there is xhr.post. example: d3.xhr('../querys/querys.php').post(JSON.stringify({a: 2, b: 3}), function(error, data) {
 // callback
 });

  • @Andre.barata good to see you here :) I had not read that the request was POST... Give an answer, so the question gets better answered :)

  • and next to php I can’t read the values ..

  • @user2964140 how are you receiving these values in PHP?

  • as post . I used the example given by the cheap Andre

  • @user2964140 hadn’t read that you needed to post. I leave an example for GET, as I said in the reply: http://jsfiddle.net/Sergio_fiddle/pxdvn83p/

  • I’m trying to make a diagram of Sankey origin destination

Show 2 more comments

Browser other questions tagged

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