我正在使用javascript从XML文件加载数据。在检查就绪状态和状态的if语句之后,文件未被加载。就绪状态返回4并且状态返回200,因此最后一个条件(responseXML)不应为null,但由于某种原因,它保持为null并且未加载XML文件。
from flask import request, jsonify, render_template
import sys
@app.route("/function_route", methods=["GET", "POST"])
def my_function():
if request.method == "POST":
data = {} // empty dict to store data
data['title'] = request.json['title']
data['release_date'] = request.json['movie_release_date']
// do whatever you want with the data here e.g look up in database or something
// if you want to print to console
print(data, file=sys.stderr)
// then return something back to frontend on success
// this returns back received data and you should see it in browser console
// because of the console.log() in the script.
return jsonify(data)
else:
return render_template('the_page_i_was_on.html')
这是javascript文件中与加载XML有关的代码。打开控制台会显示日志,告诉我代码没有通过检查asyncRequest的if语句。