如何在JS中设置XMLHttpRequest的url?

如何在JS中设置XMLHttpRequest的url?,url,Url,在somefile.html中,我使用了一个JS,其中包括XMLHttpRequest: open('GET','static/name.json',true); 当我从本地调用render_template('somefile.html')时,它工作得很好 @应用程序路径(“/”) (由于请求在此处打开文件: 但当我需要从其他地方调用render_template('somefile.html')时,如下所示: @app.route('/conference//modifysession/',

在somefile.html中,我使用了一个JS,其中包括XMLHttpRequest:

open('GET','static/name.json',true); 当我从本地调用render_template('somefile.html')时,它工作得很好

@应用程序路径(“/”) (由于请求在此处打开文件:

但当我需要从其他地方调用render_template('somefile.html')时,如下所示:

@app.route('/conference//modifysession/',方法=['GET','POST'])) 以下是Chrome Developer中显示的错误:

404(未找到) 因此,请求会自动将头添加到我不希望它这样做的文件的URL中


我如何从URL中剪切自动添加的部分?

您在get请求中使用的URL是一个相对URL,如果您在get请求中使用“/static/name.json”(注意前面的/),那将是为了

非常感谢。这花了我很多时间,而且只是一个“/”!:-)