<script type="text/javascript">
var onerror = function(res) {
alert('ERROR in call');
};
function get_fields() {
var from_note = document.getElementById("from_note").value;
var to_note = document.getElementById("to_note").value;
Q.ajax("POST", "[[=URL('report_note_intervals') ]]", {
from_note: from_note,
to_note: to_note
}).then(Q.ajax('GET', "[[=URL('report_note_intervals') ]]") ).catch(onerror);
}
</script>
use 'GET' method in .then() not work
Traceback (most recent call last):
File "/Users/MacBookPro/Downloads/py4web_cmd/py4web/core.py", line 726, in wrapper
ret = func(*func_args, **func_kwargs)
File "/Users/MacBookPro/Downloads/py4web_cmd/py4web/core.py", line 686, in wrapper
ret = func(*args, **kwargs)
File "/Users/MacBookPro/Downloads/py4web_cmd/apps/music/report.py", line 52, in report_note_intervals
from_semitone = int(request.json['from_note'] )
TypeError: 'NoneType' object is not subscriptable
<script type="text/javascript">
var onsuccess = function(res) {
var data = JSON.parse(res.data);
var html = data.header + "<table>" + "<tr><th>Note</th></tr>" + for(i in data.rows) + "<tr><td>i</td></tr>"+ "</table>"
document.getElementById('target').innerHTML = html;
};
var onerror = function(res) {
alert('ERROR in call');
};
function get_fields() {
var from_note = document.getElementById("from_note").value;
var to_note = document.getElementById("to_note").value;
Q.ajax("POST", "[[=URL('report_note_intervals') ]]", {
from_note: from_note,
to_note: to_note
}).then(onsuccess).catch(onerror);
}
</script>
try js for looping not work :
browser console
form_note_intervals:122 Uncaught SyntaxError: Unexpected token 'for'
objective
if form input change, then the function report_note_intervals is called with it's prepared html document (report_note_intervals.html)
question
how to achieve it in py4web way ?
could provide work code in web2py (using ajax function), if needed