jquery ajax call returning error when its not an error

Posted by azz0r on Stack Overflow See other posts from Stack Overflow or by azz0r
Published on 2010-04-13T16:15:55Z Indexed on 2010/04/13 16:23 UTC
Read the original article Hit count: 349

Filed under:
|

Hello,

My JS Is:

    $(InitFavorite);

function InitFavorite(){

    var jList = $(".favourite_link");
    var ids_to_check = {};//new Array();

    $.each(jList, function () {
        var id = this.id;
        var object = id.split("_");
        if (!ids_to_check[object[1]]) {
            ids_to_check[object[1]] = [];
        }
        ids_to_check[object[1]].push(object[0]);
    });

    //console.log(ids_to_check);

    $.ajax({
        type: 'POST',
        url: '/user/subscription/favourite-listing',
        data: ids_to_check,
        dataType: 'json',
         beforeSend: function(x) {
              if(x && x.overrideMimeType) {
               x.overrideMimeType("application/j-son;charset=UTF-8");
          }
         },
        error: function() {
            alert(1);
        },
        success: function() {
            alert(2);
            /*$each(returned_values, function() {
                alert('boom');
            });*/
        }
    });
}

From the ajax call, the following data is returned:

{"env":"development","loggedIn":true,"translate":{}}{"Playlist":{"10":"Stop Recieving Updates For This Playlist"},"Clip":{"26":"Recieve Updates For This Clip","27":"Recieve Updates For This Clip","28":"Recieve Updates For This Clip","29":"Stop Recieving Updates For This Clip","30":"Recieve Updates For This Clip"}}

However, success is never triggered, just error, despite there being no header and json being put out as the header (via zend framework).

Ideas?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about zend-framework