How to call an existing defined javascript function with an prototypejs ajax onSuccess event? -
all documentation can find has defining actual function call within ajax constructor
new ajax.request('/your/url', { onsuccess: function(response) { // handle response content... } });
but code throws error saying "uncaught typeerror: undefined not function" here code trying call existing function pullcomments().
function addcomment(){ // stringify json var commentstr = $('#commentbox').value; var jsonobj = { "dealid" : dealid, "username" : "default", "comment" : commentstr }; jsonobj = json.stringify(jsonobj); var jsoncomment = encodeuricomponent(jsonobj); new ajax.request("php/savecomment", { method: 'post', parameters: "comment=" + jsoncomment, onsuccess: pullcomments() }); } function pullcomments(){ // grab comments deal var xmlhttp ****
change to:
onsuccess: pullcomments
you want pass implementation of function 'onsuccess' rather result of function.
Comments
Post a Comment