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

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -