Why Does This Code Fail for Some Users?

23 views
Skip to first unread message

cutey Love

unread,
May 25, 2014, 3:09:29 PM5/25/14
to ang...@googlegroups.com
I have this code and it works for me all the time, but many users tell me it simply does nothing when they execute it, does anyone have any idea as to why?
 
$scope.purchase = function()
    {
        $scope.cam.ttype = "order";
        $scope.cam.price = $scope.cost;
        $scope.cam.bloggers = $scope.bloggerNumber;
        $scope.cam.name = $scope.order.name;
        $scope.cam.companyName = $scope.order.companyName;
        $scope.cam.email = $scope.order.email;
        $scope.cam.message = escape($scope.order.message.replace(":", ""));

        Order.query($scope.cam)
                .$promise.then(function(data) {
                    window.location = ("http://www.example.com/platform/server/confirm.php?order=" + data[0].hash);
                });
    };

cutey Love

unread,
May 26, 2014, 1:52:48 PM5/26/14
to ang...@googlegroups.com
anyone?

Steve Jackson

unread,
May 26, 2014, 4:56:16 PM5/26/14
to ang...@googlegroups.com
Not sure without running it to see what it does for me, exactly, but at first glance I see that there isn't any protection around having objects that are null. Anytime I have more than 2 dots after a variable I check for null before referencing properties...

Is it possible that you have a null reference happening? Doors anything show up in the browser's console?

Steve

Eric Eslinger

unread,
May 26, 2014, 7:45:38 PM5/26/14
to ang...@googlegroups.com

Yeah, I'd put a .catch on the end of that promise chain to see what the error is. My hypothesis is that Order.query is failing, but it is hard to say why. The problem with promises (and asyncs in general) is that unless you explicitly look for errors, you'll miss them.

Which is why I put an .catch (err) -> console.log err at least on all my promise chains. Or next err if we are on the node side.

e

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.
To post to this group, send email to ang...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

cutey Love

unread,
May 28, 2014, 5:58:50 AM5/28/14
to ang...@googlegroups.com
Fixed, the problem was a certain character being pushed to a GET query.

Steve Jackson

unread,
May 28, 2014, 6:12:39 AM5/28/14
to ang...@googlegroups.com

Good news! Glad you figured it out.

--
You received this message because you are subscribed to a topic in the Google Groups "AngularJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/angular/eKlQf-Z8GaU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to angular+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages