JSONP web service with python

后端 未结 4 1657
迷失自我
迷失自我 2020-12-16 04:26

I\'m writing an AJAX function that requests data from my JSON Python webservice. My AJAX request looks like:

  url = \"http://localhost:8001/blah\"
  $.aja         


        
4条回答
  •  时光说笑
    2020-12-16 05:03

    What happens when you use Jquery's JSONP datatype, is that a callback function name is sent as a GET param as part of your URL, so you're actually querying something like "http://localhost:8001/blah?callback=json125348274839".

    Your response from your web server should look like this:

        return "%s({'a':1, 'b':2 })" % _GET_PARAMS('callback')
    

    so your web server will return somthing like "json125348274839({'a':1, 'b':2 })"

    Hope that helps!

提交回复
热议问题