Question: Hi I just tried testing if the error function would return an alert but it didn't fire. I altered the url link hoping that it would generate an alert since it won't be able to find or get json data. All I am getting is "Uncaught TypeError: Cannot read property 'length' of undefined jquery-1.9.1.min.js:3"

```
$(document).on('pagebeforeshow', '#blogposts', function () {
    //$.mobile.showPageLoadingMsg();    
    $.ajax({
        url: "http://howtodeployit.com/api/get_recent_po",
        dataType: "json",
        jsonpCallback: 'successCallback',
        async: true,
        beforeSend: function () {
            $.mobile.showPageLoadingMsg(true);
        },
        complete: function () {
            $.mobile.hidePageLoadingMsg();
        },
        success: function (data) {
            $.each(data.posts, function (key, val) {
                console.log(data.posts);
                var result = $('<li/>').append([$("<h3>", {
                    html: val.title
                }), $("<p>", {
                    html: val.excerpt
                })]).wrapInner('<a href="#devotionpost" onclick="showPost(' + val.id + ')"></a>');
                $('#postlist').append(result).trigger('create');
                return (key !== 4);
            });
            $("#postlist").listview();
        },
        error: function (data) {
            alert("Data not found");
        }

    });
});

```

Answer: 
I think the problem is that, when you make the AJAX request your code is executing the `success` callback, not the `error` callback. Thus when you execute:

`$.each(data.posts, function(key, val) {`

The `$.each` function is trying to get the length of `data` which is NULL.

It doesn't look right that you have defined a jsonp callback function and yet your still using the `success` and `error` callbacks. This SO question might help a bit :

[Use of success / jsonpCallback with ajax request](https://stackoverflow.com/questions/7167488/use-of-success-jsonpcallback-with-ajax-request)
Thanks everyone for your input. I did take on-board all suggestions. Recommendation from Jason seems to had made more sense so while investigating his suggestion I came to this [site](http://api.jquery.com/jQuery.ajax/) to read up more about jasonCallback. removing the jasonCallback option though did not fix the issue but strangely this issue seems to do with the url I was using for my json caalback.

What I then did was to change the url from "<http://howtodeployit.com/api/get_recent_po>" to "<http://howtodeployit.com/category/daily-devotion/feed/?json=recentstories>" and it worked. Even though both returned error in the console but the second was the one that triggered the error function. Why I am looking into it.