javascript - Unable to parse data using ajax in phonegap -
i want parse data server using ajax: projects.js:
$("#projects").click(function(){ $.ajax({ url: "http://192.168.0.49:1080/plw6.2/admin/opx2admin/192.168.0.49:9400/odata/project?%24select=name%2cstatus", type: "get", datatype: 'json', //success of authorization success: function(result){ var tr; var str = json.stringify(result); obj = json.parse(str); for(var = 0; < obj.value.length; i++) { tr = $('<tr/>'); tr.append("<tr><td class=\"project_title\">" + obj.value[0].name + "</td></tr>"); tr.append("<tr><td class=\"project_status\">" + obj.value[0].status + "</td></tr>"); tr.append("<tr><td class=\"project_date\">" + obj.value[0].real_start + "</td></tr>"); $('.project_info').append(tr); } }, //failure of authorization error: function(jqxhr, status, errorthrown) { alert("error"); } }); });
projects.html:
<div class="project_info"> <table> <tbody> <tr> <td class="project_title">project1</td> </tr> <tr> <td class="project_status">active</td> </tr> <tr> <td class="project_date">03/2017-05/2018</td> </tr> </tbody> </table> </div> <script type="text/javascript" src="./js/projects.js"></script>
i can't data server path of server correct.how can fix that?
what data returned server? put console.log( result ) success()
you need allow phonegap access external servers using allow-intent params... see https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/
so... html table isn't correct (no have table /table)
Comments
Post a Comment