1

I've found no way of solving this.

I have a jQuery ajax call that has always worked. I'm creating a new app with Angularjs (I'm new) and my new, Angularjs, ajax worked perfectly. When I test published to azure I found the code no longer worked. It gives an error of 0. I kid you not. I put the code in plunker and got the same result.

I have read and tried a bunch of things. I even tried using the jQuery ajax to populate the angularjs $scope.myData . By the way it populates it correctly, however Angular doesn't seem to be aware that it has new data?

Any help would be great. Thanks in advance. ;-)

I don't actually need the App Key since i setup azure to accept get requests from anyone, but in trying a bunch of stuff...

// Angular version:

$http({ method: 'GET', url: fullUrl, headers: { 'X-ZUMO-APPLICATION': AppKEY, 'Content-Type': 'Application/json' } })
.success(function (data, status) {
    // Success
    angular.copy(data, $scope.data);

})
    .error(function (data, status) {
        // Error
        alert(status);

    });

And here is the jQuery:

$.ajax({ 
    url: startOfUrl + "recetas",
    headers: {
        "x-zumo-application": AppKEY
    },
    dataType: 'json',

    success: function (data) {
        // My work
    },
    error: function (x, status, Err) {
        alert(status);
    },
    complete: function () {

    }

1 Answer 1

1

You say you have a Plunkr but didn't include the link so it's hard to debug. What you've written isn't a 1:1 replacement for your $.ajax call. A few comments:

  1. Content-type isn't supposed to be case-sensitive, but I've seen plenty of servers that didn't fully comply with the spec. Try "application/json" instead.

  2. In one spot you're passing in the appkey header in lower-case, and it's upper-case in the other. This will almost certainly cause trouble - most custom app servers I've seen are definitely case-sensitive here.

  3. You don't say where you get this error. Is your .error() callback actually getting triggered, or are you getting a data block back of 0?

  4. You're forming your URLs differently in each call.

It's enough that without knowing more it's impossible to guess what's wrong. If you can create a Plunkr that demonstrates the problem that would help a lot.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! I'll look into that, put my Plunkr in order and post it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.