Searched for onComplete issues; none are close to what I'm experiencing.

21 views
Skip to first unread message

Jack Drysdale Jr

unread,
Jan 9, 2014, 4:28:18 PM1/9/14
to mootool...@googlegroups.com
Hello, everyone.

I've got a function that is called whenever specific input field values are changed.  The onRequest is firing, no problem.  But the onComplete does not do anything.  At all.  I've placed alerts, they don't fire.  I used try/catch, nothing.


    var vtr = new Request.JSON({
        url: root + '/abc/def/ghi/component.cfc?method=tmcu&id=' + ID,
        onRequest: function(){// works fine..
            $('tmc').set('text','Calculating...');
        },
        onComplete: function(json, text){
            json = JSON.decode(json);
            if(json == null){
                json = JSON.decode(text);
            }
            if (typeOf(json) != 'object' || typeOf(json.tmc) == 'null') {
                // ...check to see what kind of error was returned.
                jsonDataSessionCheck(json);
            }else {
                if([11,40].contains(json.bc.toInt()) && ! [11,40].contains($('bc').get('text').trim().toInt())){
                    myParent().$('ocr').fakeEditClick();
                }else if (! [11,40].contains(json.bc.toInt()) && [11,40].contains($('bc').get('text').trim().toInt())){
                    myParent().$('ocr').fakeEditClick();
                }else{
                    $('tmc').set('text',json.tmc); // THIS IS SUPPOSED TO CHANGE THE TEXT OF AN ELEMENT.  IT'S NOT.
                    $('bc').set('text',json.bc);
     // THIS IS SUPPOSED TO CHANGE THE TEXT OF AN ELEMENT.  IT'S NOT.                }
            }           
        }
    })


For the life of me, I cannot understand why the onComplete is not firing.  Can anyone think of anything that would prevent onComplete from firing?

Thanks,

JD

Johnny Fuery

unread,
Jan 9, 2014, 4:30:20 PM1/9/14
to mootool...@googlegroups.com
I think you'll get what you expect if you change 'onComplete' to 'onSuccess'.


Johnny Fuery
President/Principal Engineer
Fuery Solutions -- makers of MerusCase
1736 Franklin Street, Suite 350
Oakland, CA 94612


--
 
---
You received this message because you are subscribed to the Google Groups "MooTools Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mootools-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Jack Drysdale Jr

unread,
Jan 9, 2014, 4:49:47 PM1/9/14
to mootool...@googlegroups.com
Hi, johnnyf,

Thanks for the quick reply.  I cleared the cache and tried what you suggested.  Unfortunately, no change.  It still isn't updating the text of any elements, still no alerts.

This really has me perplexed.  Similar functions for other sections are working, just fine.  Just this one doesn't want to follow through.

JD

Johnny Fuery

unread,
Jan 9, 2014, 5:04:11 PM1/9/14
to mootool...@googlegroups.com
Ok. Try the following:

1. console.log() the contents of json. You'll want to do the same at a couple of other spots in your example to validate that your conditions are working as expected.
2. Create a JSfiddle with an example. This will force you to simplify some items and will help everyone monitoring this list assist you.
3. You can console.log an element, e.g., $('tmc'). This is helpful to make sure the DOM is drawn as you intend/expect.

Hope this helps.

Sérgio Crisóstomo

unread,
Jan 9, 2014, 8:11:56 PM1/9/14
to mootool...@googlegroups.com
Jack, what do you get when you use:

        onSuccess: function(json, text){
            console.log(json, text);

? ie, is it empty?

/Sergio

Dimitar Christoff

unread,
Jan 9, 2014, 9:12:29 PM1/9/14
to mootool...@googlegroups.com

Er. Maybe my mootools is a little rusty but.

https://github.com/mootools/mootools-core/blob/master/Source/Request/Request.JSON.js

This will fire an error event when it fails to parse the response.

request.json automatically passes the object/array. No need to do so manually or just use request.js itself.

Most errors with this tend to be to do with invalid response or content-type issues. validate the response in console and json validators, ensure it's not 204 nocontent etc.

onComplete is supposed to always fire, though.

Jack Drysdale Jr

unread,
Jan 10, 2014, 9:11:46 AM1/10/14
to mootool...@googlegroups.com
I placed a console.log in the onRequest, and the element is being drawn correctly.  Placing a console.log in the onComplete (also tested in onSuccess) didn't do anything.  The onSuccess runs a CFC that will update the database with the new value - that much is being done - but after the CFC is completed, the onSuccess/onComplete does not fire (checks to see that the data returned is JSON - it is - and processes from there.

Unfortunately, I work in a DoD environment, and both github and jsfiddle are BLOCKED.  Can't even get a glimpse of the site - "internet usage is blocked for this site".  :(

JD

Jack Drysdale Jr

unread,
Jan 10, 2014, 9:14:08 AM1/10/14
to mootool...@googlegroups.com
Sergio,

Thanks for your reply.  Absolutely nothing happens when I replace my current onSuccess with just console.log.  :(

JD

Jack Drysdale Jr

unread,
Jan 10, 2014, 9:27:11 AM1/10/14
to mootool...@googlegroups.com
Thank you to everyone who responded to my question.  A supervisor just figured it out.  Apparently, something had changed recently that started breaking our JSON data format.

Please keep in mind that I inherited this code.

Originally, the JSON was being returned as {var1:"val1", var2:"val2"}.  Now, we are slowly discovering more and more code that needs to have the variables in quotes.  This was preventing the onSuccess from firing.

Thank you,

JD

Jakob Holmelund

unread,
Jan 10, 2014, 10:39:50 AM1/10/14
to mootool...@googlegroups.com
Well.. Correct JSON needs to have the quotes, so it would probably be for the best if you guys fixed that.


Reply all
Reply to author
Forward
0 new messages