在ajax成功调用中调用/引用python变量?

时间:2021-12-01 23:17:28

How to call python variables in ajax success call?

如何在ajax成功调用中调用python变量?

I fed the HTML form inputs through ajax post call to python backend, and as part of ajax succcess call i need to call python variables to build the <tbody> of the html table.

我通过ajax post调用python后端提供HTML表单输入,并且作为ajax succcess调用的一部分,我需要调用python变量来构建html表的。

{{ login_id }} doesn't seem to be working in Ajax, but does in html code. Some direction on this is greatly appreciated

{{login_id}}似乎不是在Ajax中工作,而是在html代码中工作。对此的一些方向非常感谢

this is a snippet from the ajax success code,

这是ajax成功代码的片段,

html += "<\td>" + "{{ login_id }}" + "<\/td>\", 

this results in undefined value.

这导致未定义的值。

1 个解决方案

#1


0  

The {{login_Id}} works in your HTML template because it's further interpreted by python during the page construction.

{{login_Id}}适用于您的HTML模板,因为在页面构建过程中它会被python进一步解释。

In your ajax call response you gotta use JavaScript itself in order to update the current HTML.

在您的ajax调用响应中,您必须使用JavaScript本身才能更新当前的HTML。

The login_id value needs to be in the ajax response, then you'll do something like:

login_id值需要在ajax响应中,然后你会做类似的事情:

response = function (data) { document.getElementById("elementId").innerHtml = data.login_id; ... }

response = function(data){document.getElementById(“elementId”)。innerHtml = data.login_id; ...}

I hope that might help.

我希望这可能有所帮助。

#1


0  

The {{login_Id}} works in your HTML template because it's further interpreted by python during the page construction.

{{login_Id}}适用于您的HTML模板,因为在页面构建过程中它会被python进一步解释。

In your ajax call response you gotta use JavaScript itself in order to update the current HTML.

在您的ajax调用响应中,您必须使用JavaScript本身才能更新当前的HTML。

The login_id value needs to be in the ajax response, then you'll do something like:

login_id值需要在ajax响应中,然后你会做类似的事情:

response = function (data) { document.getElementById("elementId").innerHtml = data.login_id; ... }

response = function(data){document.getElementById(“elementId”)。innerHtml = data.login_id; ...}

I hope that might help.

我希望这可能有所帮助。