In my js I make a simple request as below
$.post('/loadFcs', function(data) {alert('hi');});
In my urls.py, I have
from views import loadFcs
urlpatterns = patterns('',
('^$', direct_to_template, { 'template': 'index.html' }),
('^loadFcs$', loadFcs)
)
In my views I have
@require_POST
def loadFcs(request):
results = {}
//do some calculation and calucalte results, results looks like {"a":["avalue", "bvalue"], "b":["avalue", "bvalue"]}
return HttpResponse(json.dumps(results),mimetype="application/json")
But I see the following error in my Firebug console under the 'Response' tab
TypeError at /loadFcs expected string or buffer
Request Method: POST
Where am I making a mistake? I also tried just
return HttpResponse(json.dumps(results))
but did not work either.