0
  $(".btn-primary").click(function(){ 
  success(jsonObj); 
  });

In the JSFiddle Code how do I reload only the container. everytime I change the JSON I need to RUN the code, how can I do it with the button

usercode
  • 309
  • 4
  • 20
  • You mean like push notifications? Like the server letting the client know of a change? That's pretty complicated, but it certainly can be done with websockets. what about polling the JSON every X seconds? – Benjamin Gruenbaum Jun 28 '13 at 12:14
  • Just to be sure, you mean the JSON _string_ right? – Benjamin Gruenbaum Jun 28 '13 at 12:19
  • 1
    If I'm understanding what you're asking, there's nothing wrong with your code that I can see. The issue is that what you're trying to do is outside the scope of what JSFiddle can do. When you change things in js fiddle, it doesn't dynamically change your javascript as well, you have to reload the page for it to reload your javascript. – Jeff Lauder Jun 28 '13 at 12:29
  • Jeff You got me correctly. but the problem is in my demo http://helloworld.site44.com/ I face the same problem. – usercode Jun 28 '13 at 12:31
  • You never change the value of `jsonObj`, so clicking the button will always load the same value. It looks like you want to put the `$.getJSON` call into the click event handler, i.e. `$(".btn-primary").click(function(){ $.getJSON("...", success); });` – Felix Kling Jun 28 '13 at 12:36

1 Answers1

1

The Solution was simple. It was a cache problem. Just need to add

      $ajaxSetup({cache: false}); //in the call back function 

and

      $ajaxSetup({cache: true});
usercode
  • 309
  • 4
  • 20