2015-05-06 54 views
0

在somefile.html中,我使用一個包含這個XMLHttpRequest的JS:如何在JS中設置XMLHttpRequest的URL?

request.open('GET','static/name.json',true); 它運作良好,當我打電話render_template( 'somefile.html')從地方

@ app.route( '/') (由於請求打開此文件:http://localhost:5000/static/name.json

但是,當我需要從其他地方調用render_template('somefile.html')如下:

@ app.route('/ conference // modifysession /',methods = ['GET','POST']) 這是在Chrome Developer中顯示錯誤:

http://localhost:5000/conference/16/modifysession/static/name.json 404(NOT FOUND) 因此,請求會自動將標題添加到我不想要的文件的URL中。

如何從URL中剪切自動添加的部分?

回答

0

您使用的是您的GET請求的URL是相對URL,如果使用「/static/name.json」(注意前導/)在您的GET請求,這將是http://localhost:5000/static/name.json

+0

謝謝非常。我花了很多時間,這只是一個'/'! :-) –