mysql - How to show Json data to the dialog box in html -
mysql - How to show Json data to the dialog box in html -
i beginner in ajax, dom, jsonm etc in web application. project utilize jquery ui parse json info , show of info database , retrive 1 info id, it's part of create, retrieve, update, , delete. retrieving key function here. can info , populate datatable info no problem.
"aocolumns" :[ {"mdata" : "image"}, {"mdata" : "name"}, {"mdata" : "type"}, {"mdata" : "description"}, {"mdata" : "price"}, {"mdata" : "id", "mrender" : function(data, type,full) {return '<a href="#" id="'+ full.id + '" class="id">details</a>'; } }
-->to fetch data
var findbyid= function(id) { console.log('findbyid: ' + id); $.ajax({ type:'get', url: rooturl + '/' + id, datatype: "json", success: renderlist }); }; var renderlist = function(data){ var list = info == null?[] : (data instanceof array ? info : [ info ]); /////////////////////////////////// solution1////////////////////////////////////////////////// $.each(list, function(index, pet){ var row="<tr>" + "<td>" + pet.type + "</td>" + "<td>" + pet.price + "</td>" + "<td>" + pet.contact_no+ "</td>" + "<td> "+ pet.contact + "</td>" + "</tr>"; //$(tblrow).appendto("#entrydata tbody"); $(row).appendto('dialogtable tbody'); });
to retrieve more details
the result(in xml) show if click "details " link checking element,
<pet> <contact>bob.hoskins@lgfriday.com</contact> <contact_no>5-(254)756-8567</contact_no> <description>great companion 75 years</description> <id>42</id> <image>bird</image> <name>amazon</name> <price>40</price> <type>birds</type> </pet>
(failed) net::err_connection_refused
the info coming in mediatype.application_json, mediatype.application_xml can check info type cant create connection show in dialog box
<div id="dialog" title="more information"> <table id="dialogtable" style="width: 350px;"> <thead> <tr id="findbyid"> <th>type</th> <th>price</th> <th>contact</th> <th>email</th> </tr> </thead> <tbody> </tbody> </table> </div>
i resolved problem. had set var rooturl = http://localhost/xxx/rest/xxx";
instead of rooturl = "http://localhost:8080/xxx/rest/xxx"
. solved cross origin connection , connection failure problem , renders.
html mysql ajax json datatable
Comments
Post a Comment