Jorge Godoy wrote:
> "Javier Rojas" <[EMAIL PROTECTED]> writes:
>>I've been
>>reading mochikit's doc and I think the problem might be with the http
>>code returned. When an exception is raised in a controller, the return
>>(HTTP) code changes? that might be causing my callbacks to not be
>>called....
>
>
> Of course it changes! You get an error and the return code is an error code.
> You have to add the errback. :-)
No, he is catching the exception with "except Exception"* and returns a
different dict with just the error message. And that's where the error
lies: Javier, you have to check in your JS callback function, if the the
received object really contains an id (untested):
function dos (d) {
if (d["tg_errors"]) {
alert(d["tg_errors"]);
return;
}
if (d['id']) {
select = document.getElementsByName("persons")[0];
last = select.options[select.options.length-1];
removeElement(last);
appendChildNodes(select,
OPTION({"value":d["id"]},d["nombre"]),last);
} else {
alert("Error inserting name in database!");
}
}
(Keep in mind that in JavaScript every statement ends with a semicolon.)
* this is bad practice. Find out the type of exception that is raised
when the key already exists in the database and just catch that.
HTH, Chris
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---