Multiple button click handling

In my html page I have 4 buy buttons. On clicking each button corresponding datas will be populated in a popup. Its working fine. But among these 4 buttons two are having same data. So I dont need a separate call to get this data. I want to check whether the data is already loaded there in the page and if yes that needs to be populated. I'm using ajax with JSON for fetching data from back end. Please help me out.

Thanks in advance.

Adding the fiddle

Here if u check using firbug>Net at the bottom we can see 4 json responses happened already loaded. I need to avoid this, because all these four resposes are duplicate


When using jquery ajax you can simply let jQuery do the caching work.


    cache: true,

    success: function(data) {

        // do something now that the data is loaded


    url: '/path/to/my/json/file.js'


I would have used jQuery and made something general :

$('.buybutton').click(function() {

Just put the class="buybutton" to each buy button and do the check if data is loaded into your function.

Need Your Help

What is needed to make an online “checkers” game on the web?

php javascript html mysql html5

As an experiment I was planning on making a board game, and so I chose checkers, but I have one problem. The game is fairly easy to make as a single player game on the web, but I would like to know...

How to retrieve all the classes for certain object

php class oop object

I am trying to check one object using var_dump

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.