Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- GAE ajax
- clone : http://pastebin.com/CAceZLDK
- in response : http://stackoverflow.com/questions/19250831/python-gae-render-an-image-returned-from-ajax-post-json-format#comment28537691_19251636
- http://stackoverflow.com/q/19250831/2541442
- # main.py
- class DoubleNumbers(webapp2.RequestHandler):
- def get(self):
- pass
- def post(self):
- #self.response.headers['Content-Type'] = 'application/json'
- data = json.loads( self.request.body )
- z = data['imageSrc']
- logging.info(z)
- self.response.write(z)
- # JS
- $(document).ready(function() {
- $("button").click( function(){
- console.log("PRESS");
- var data = { 'imageSrc' : 'https://www.google.com.br/images/srpr/logo6w.png' };
- var request = $.ajax( { cache: false,
- url: "/i",
- type: "POST",
- data: JSON.stringify(data),
- //dataType: "json"
- }).done( function(data){
- var txt = "<!DOCTYPE html><html><body><img src='"+data+"'></body></html>";
- document.open("text/html");
- document.write( txt );
- document.close();
- console.log(data);
- console.log(txt);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement