//jPut HTML Template (it will he hidden) <div jput="template1"> <div class="items" id="item_{{id}}"> <h1>{{name}}</h1> //for image tag to avoid error put 'jsrc' instead of 'src' <img jsrc="/images/{{image_loc||default.jpg}}" alt=""/> <span>{{description}}</span> </div> </div> <div id="main"> </div>
//JSON Data var projects=[{"id":"8","name":"name1","description":"This is a test","image_loc":"image1.jpg"}, {"id":"9","name":"name2", "description":"Test 2","image_loc":"image2.jpg"}];
//The div you want to upload $('#main').jPut({ dataName:'', //object name if the json data is in specified object jsonData:data, //(jsonData/ajax_url) is required your json data to append/prepend ajax_url:'http://yourdomain.com/data.json', //ajax:Specifies the URL to send the request to. Default is the current page ajax_data:'', //ajax:specifies data to be sent to the server ajax_type:'', //ajax:specifies the type of request. (GET or POST) name:'template1', //*required field jput template name limit:0, //default:0 limit the number of record to show prepend:false, //default:false If you want to prepend data make it true. By default data will append done:function(e){ //on success (e will be the json data) }, error:function(msg){ alert('Error Message:'+msg); //On error } });