Django: JSON response for AJAX pulling

I have strange error, try to solve it in different ways.
In general — i got response 200 and success status but data in empty, even when i browse data by url.
One of code examples:
Django View:

def api_recent_news(request):
    news = News.objects.all()[:2]
    r = [model_to_dict(v) for v in news]
    return JsonResponse(r, safe=False)

This was i have nice JSON in browser.
But when i try pull it with AJAX:

var url = 'http://this-is-my-url/api-recent-news/';
   type: "GET",
   url: url,
   dataType: "jsonp",
   success: function(data) {
     console.log('Fetched ' + data.length + ' items!');
   error: function(e){

So i got this response in console:

Object {readyState: 4, status: 200, statusText: "success"}abort: ( statusText )always: ()complete: ()done: ()error: ()fail: ()getAllResponseHeaders: ()getResponseHeader: ( key )overrideMimeType: ( type )pipe: ( /* fnDone, fnFail, fnProgress */ )progress: ()promise: ( obj )readyState: 4setRequestHeader: ( name, value )state: ()status: 200statusCode: ( map )statusText: "success"success: ()then: ( /* fnDone, fnFail, fnProgress */ )__proto__: Object

Source: json

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.