我想从我的web应用程序中使用我自己的API。
这或多或少是我想要做的,但是在我的API的控制器中:
在前端,用户引入了两个值,这两个值应该被发送到API,然后在我的控制器中进行一些计算,最后在我的视图中得到结果。我已经这样做了,但是假设是在普通的控制器中(不是api/v1中的那个)。
我的index.html.erb是:
<div >
<p class="mod1_title">Mein Lastprofil berechnen</p>
<div class="mod1_boxed">
<strong>Jahreshausverbrauch (kWh):</strong>
<%= form_tag( '/calculation/index', post: true ) do %>
<%= text_field_tag "user_entry_module1", nil, placeholder: "Bsp. 3500", id: "user_entry" %></br>
<strong>PV-Große (kWp):</strong></br>
<%= text_field_tag "user_entry_module2", nil, placeholder: "Bsp. 5", id: "user_entry_2" %></br>
<%= submit_tag "Berechnen"%>
<%end%>
</div>
</div>
Ergebnis: <%= @a %> 有人能告诉我如何做到这一点吗?
发布于 2015-07-02 17:30:00
从我的Rails应用程序调用API。我使用了一个来自javascript的AJAX调用。
https://stackoverflow.com/questions/30599721
复制相似问题