Any changes in the function ajax of the application scaffold?
The following code works in an old application
<form>
<input type="hidden" id="id" value="" />
</form>
<div id="submenu">
{{for r in rows:}}
<span onclick="$('#id').attr('value','{{=r.id}}');
ajax('bg_myfunction', ['id'], 'target');">
{{=r.name}}
</span>
{{pass}}
</div>
<div id="target"></div>
def bg_myfunction():
id = request.vars.id
return id
But in a new, created from the application of scaffolding does not
work, request.vars is always None.
the old function ajax (works fine) is:
function ajax(u,s,t) {
var query="";
for(i=0; i<s.length; i++) {
if(i>0) query=query+"&";
query=query+encodeURIComponent(s[i])
+"="+encodeURIComponent(document.getElementById(s[i]).value);
}
jQuery.ajax({type: "POST", url: u, data: query, success:
function(msg) { if(t==':eval') eval(msg); else
document.getElementById(t).innerHTML=msg; } });
}
the new function ajax is:
function ajax(u,s,t) {
query = '';
if (typeof s == "string") {
d = jQuery(s).serialize();
if(d){ query = d; }
} else {
pcs = [];
for(i=0; i<s.length; i++) {
q = jQuery("#"+s[i]).serialize();
if(q){pcs.push(q);}
}
if (pcs.length>0){query = pcs.join("&");}
}
jQuery.ajax({type: "POST", url: u, data: query, success:
function(msg) { if(t) { if(t==':eval') eval(msg); else jQuery("#" +
t).html(msg); } } });
}
is a new way of working with the new function or it has a bug?
Regards,
Jose