0

This is how i am passing a json object in views.py

json_data = json.dumps(filedata, default=lambda obj: obj.__dict__,indent=4)    
return HttpResponse(json_data, mimetype='application/json')

And I am reading the file in jquery using ajax...

$.ajax({
   type: "GET",
   url: "http://127.0.0.1:8000/project/defparser/",
   dataType: "jsonp",
   success: function(data) {
       alert('Fetched ' + data.length + ' items!');
   });

But its showing an error saying data is null in the browser... There is a problem of cross domain restriction because i am accessing a django server file from a standalone html file.... How to resolve it????

1 Answers1

0

The callback function should be 3rd parameter to getJSON I believe.

Check out the docs.

But the example is missleading as it suggests existance of 2 parameter version of this function.

Krzysztof Szularz
  • 5,151
  • 24
  • 35