2016-10-26 41 views
1

我是新來的Javascript,並試圖找出如何正確寫這個。回撥地獄幫忙,在回撥裏寫一個函數

$.get("https://localhost:8090/", function(response) { 
    console.log(response) #this works as expected 
    $.get("https://localhost:8090"+response), function() { 
     console.log('response') #nothing is printed 
    }; 
}) 

$.get("https://localhost:8090/"的響應是/oauth2callback。在我的服務器(燒瓶)上,我啓用了日誌記錄功能,我可以看到路由中的功能正常運行。

服務器的代碼看起來是這樣的:

@app.route('/oauth2callback') 
def oauth2callback()  
    if 'code' not in flask.request.args: 
     logging.warning('code not in args') 
     auth_uri = flow.step1_get_authorize_url() 
     logging.warning(auth_uri) 
     return auth_uri 

我可以在日誌文件auth_uri是準確的看到。

但是,我沒有看到console.log('response')被打印在我的控制檯中。我認爲這是由於我的可憐的Javascript技能,而不是正確書寫回調?

我該如何構造這個?

謝謝!

回答

4

你有一個額外)錯誤

$.get("https://localhost:8090"+response), function() { 
// ....................................^ remove this paren 
}); // <--- and add it here 
+0

啊!謝謝!修復它:-) –

+0

不客氣的隊友:) – nem035