![](/img/trans.png)
[英]How do I send an array of hashes as a parameter in a jQuery.get() request?
[英]how do I send a GET request with Jquery?
目前,我正在使用Flask和Jquery,並在控制台中收到500 Internal Server Error響應。 當我用Ajax發布到flask上的url時,是否應該可以接收它? 我不明白為什么會收到此錯誤。
jQuery的
$('.movie').click(function(){
console.log(this);
$(this).toggleClass('green blue').promise().done(function(){
if ($(this).html() == "Add Movie"){
$(this).html("Added");
}
});
id = $(this).val();
//get information from API
$.ajax({
url: "/profile",
dataType: 'json',
async: true,
data: {id: id},
success: function(data) {
}
});
Python /燒瓶
@app.route("/profile", methods = ["GET"])
def profile(id):
print("mydata is: ", request.args['id'])
if request.args.get:
print("this API is reached")
id = request.args.get['id']
url_movie = 'https://api.themoviedb.org/3/movie/{}?api_key=78cb6b67a99ce26e6d6619c617d9c907&language=en-US'.format(id)
r = requests.get(url_movie)
code = r.json();
return jsonify(code)
500是服務器錯誤。 僅在服務器端執行請求有問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.