Using JQuery AJAX to grab some data from the Database and print them out according to each DIV ID -
i trying grab data database using jquery ajax, , print data div unique id.
i got 2 div tags this:
<div id="1" class="myclass"> content texting1 : $printing result test table id=1 </div> <div id="2" class="myclass"> content texting2 : $printing result test table id=2 </div>
here function in controller:
function findcontent($id=null){ $this->autorender=false; $result=$this->test->findbyid($id); if($result){ return $result['content']; } else{ return "nothing"; } } <script type="text/javascript"> $(document).ready(function(){ var id=$("div #myclass").val(); // stuck on line of code var curl="http://localhost:8080/test/findcontent"+id; $.ajax({ type: "post", url: curl, success: function(data) { var w=data.substring(0,1); alert(data); }); }); }); </script>
i have no idea how move on since there more 2 div tags in case.
need help.
try this
$.ajax({ type: "post", url: curl, success: function(data) { $("#1").html(data); $("#2").html(data); }); }); });
do want add same data in both div?
Comments
Post a Comment