i'm trying getting questions by tags.
this is my simple code and i'm running this from my http://localhost
:
<script type="text/javascript">
$(function(){
$.ajax({
url:'http://api.stackoverflow.com/1.1/search?tagged=php&page=1&pagesize=15',
dataType:'jsonp',
type:'GET',
error:function(e){
console.log(e);
},
beforeSend:function(){
},
success: function(data){
data = JSON.parse(data);
$.each(data,function(e){
$("#wrapper").append(data[e].total);
});
}
});
});
</script>
then i receive an error in console:
SyntaxError: invalid label
"total": 2000,
search...8184757 (line 2, col 2)
seems the error is generated by the json returned format, cause "total" is a result key.
how can i fix this??