469,917 Members | 1,474 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Insert values from Json Array using Ajax?

Hello,

I am trying to use Ajax in order to improve the speed of my website. I am trying to pull data from a dynamic page and insert the data onto the current page.

There are 3 three things I am trying to accomplish:
1) Have a user click a checkbox to toggle the change of data
2) Pull data from another dynamic page
3) Show that data on the current page that was clicked with a checkbox

Here is the checkbox region of the code:
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2. $('input[type=checkbox]').live( 'click', refreshData );
  3. </script>
  4.  <input type="checkbox" id="checkbox_<?= $statistic_id; ?>" <?= $i==0 ? 'checked="checked"' : null; ?> />
  5.   <label for="checkbox_<?= $statistic_id; ?>"><?= getStatisticFromId ( $statistic_id ); ?></label>
  6.  
$stastic_id is a value that varies between 1 and 100. getStatisticFromId ( $statistic_id ) returns the name of the Statistic.

The page that I am pulling data from is hosted here: http://tyrone.pae.me/pulldata.php?p=1&s=1. As the value for p varies it changes the data. As the value for s varies it changes the data. s is the $statistic_id referenced above.

Here is the code to show the data on pulldata.php on the current page:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2.    function refreshData() {
  3.    var url = "/frontend.php?p=" + tags + "&s=" + statistic + "&y=" + year;
  4.    $.getJSON( url,
  5.    function(data_from_pulldata){
  6. var data = data_from_pullata;
  7. </script>
  8.  
You'll notice the refreshData function I am trying to run in the Ajax portion is referenced above.

If you can provide any assistance on how I can make all three steps of this process work I would be very appreciative.
Oct 18 '10 #1
0 1538

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Sunil | last post: by
4 posts views Thread by googleAcct | last post: by
1 post views Thread by dan.goyette | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.