I have a php web service returning json data. My problem is that when i call the json data from url returns nothing but when a call a local file with exactly the same data (copy from the url) works fine.
The json data i receive are for example
{"ResponseData":[{"Code":"91010001","Description":"ISADORA ","retailprice":"52.0000000000"},{"Code":"91010002","Description":"ISADORA ","retailprice":"52.0000000000"}]}
The script i use to get the json data is
<script>$.getJSON("url",
function(data){
var output = '';
$.each(data.ResponseData, function(i,data){
output += '<li><a href="#">' + data.Code + '</a></li>';
if ( i == 50 ) return false;
});
$('#listview1').append(output).listview('refresh');
});
</script>
Finally, I used an ajax script just to display the json data but returns me error [object Object].
<script>
var obj
$.ajax({
url: 'url",
type: "GET",
dataType: 'json',
success: function( data ) {
alert( "SUCCESS: " + data );
},
error: function( data ) {
var obj = $.parseJSON(JSON.stringify(data));
alert( "ERROR: " + data );
}
});
</script>
Do you have any idea how to fix this?
Thanks in advance
EDIT:
Hope this helps: In application craft i used first a function obj2json to convert data to json and then json2obj to populate data.