0

I am taking in bunch of inputs from the user in html which I am then passing on to ajax query to get the response.

           $.ajax({
              url:"http://0.0.0.0:8080/getReport",
              type:"GET",
              data:JSON.stringify(out),
              dataType:"json",
              contentType:"application/json"
           })

Here is the Flask code that serves the above request.

@app.route('/getReport', methods=['GET'])
def report():
    return Response('this is a sample response')

The above method is returning the response which I can catch in complete argument of ajax but I don't understand as to why it is not displaying Response? (which will be just the text on entire page.)

pg2455
  • 5,039
  • 14
  • 51
  • 78
  • 2
    Shouldn't you set dataType as html? (see http://stackoverflow.com/a/18701357/4653485) – Jérôme Apr 25 '16 at 16:36
  • Yes. I almost forgot about that. But still I am not able to display the html in new tab and it looks like it is removing all the newline characters in my response. – pg2455 Apr 25 '16 at 16:52
  • This question helps in correcting what I was doing wrong above: http://stackoverflow.com/questions/36846784/ajax-get-request-not-working-with-flask/36849069#36849069 – pg2455 Apr 27 '16 at 16:05

0 Answers0