Line with jQuery AJAX problem


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Hannah on 10th December 2012
I've got a page do.php?Case=14
when I pass url parameter 'case' it gets my data out out of the database and draws my a realy fine chart! So I'm happy

but when I make a jquery GET request like
$.get('do.php,{Case:l4}, function(data){ $('#CHART').html(data) });
}// end f

I get a the data returned but a a blank space where the chart supposes to be

help!
Posted by RGraph support on 10th December 2012
Hi,

Sorry - I can't help you with jQuery issues. I would suggest that you check your console to see if any error messages are being logged. This is CTRL+SHIFT+J in Chrome and F12 in MSIE.
Posted by Hannah on 10th December 2012
No errors what so ever!
so, it works on the do.php (server side to get data and chart)
but not on the client who triggers this page by click


Posted by RGraph support on 10th December 2012
Hi,

You can use the RGraph function:

p()

To verify what the variable contains (the one you think should contain your data). It's little more than a glorified alert() function.
Posted by Hannah on 10th December 2012
I think it's something with the request ..
I return the whole html with the chart in it.

I think it's better to get the data and build the chart on the page I send my request from.

the problem is I got 4 arrays to vars
RGraph.ObjectRegistry.Clear();
    var jdata = <?php echo json_encode($data ); ?>;
    var jdate = <?php echo json_encode($date ); ?>;
    var jlevel = <?php echo json_encode($level ); ?>;
    var jlabel = <?php echo json_encode($label ); ?>;

and I don't have a clue how to get them on the page I draw the chart on

Posted by RGraph support on 10th December 2012
Hi,

It's not just better - it's necessary. Try looking at this page:

www.rgraph.net/docs/howto-using-ajax.html

Only your data should be transferred in the AJAX request - the chart is made in the browser.
Posted by Hannah on 10th December 2012
Works like a charm now! THX a million!
i get the data back as response txt

but, the Y labels and Tooltips are also dynamic
Do I make an onther request on another page?
or can I get the output on the same page?
in a way ...

thx HannaH

  
Posted by RGraph Support on 10th December 2012
Hi there,

You can send everything back as part of the same JSON data - like this:

view-source:www.rgraph.net/getdata.html?json

When you've got everything up and running I'd appreciate it if you could remember to link to the RGraph website - thanks!
Posted by Hannah on 11th December 2012
Works like a charm!

thx
will do!

Add a reply

 




« Back to message list
RGraph on social media