Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: a is null [closed]

I'm using the following jQuery Ajax call... anyhow it's not working.

Error:TypeError: a is null

Here is my Code:

var prefixUrl = "autocomplete?action=complete&id=";
$('#complete-field').bind('keyup', function(){
var url =  prefixUrl + escape($('#complete-field').val());
$.ajax({
    type: "GET",
    getUrl:url,
    dataType: "xml",
    success: function(responseXML) {
        var composers = responseXML.getElementsByTagName("composers")[0];
        if (composers.childNodes.length > 0) {

            $('#complete-table').css("border", "1px solid green");
            $('#complete-table').css("margin", "128px 0 0 -82px");

            for (var loop = 0; loop < composers.childNodes.length; loop++) {
                var composer = composers.childNodes[loop];
                var firstName = composer.getElementsByTagName("firstName")[0];
                var lastName = composer.getElementsByTagName("lastName")[0];
                var composerId = composer.getElementsByTagName("id")[0];

                appendComposer(firstName.childNodes[0].nodeValue, lastName.childNodes[0].nodeValue, composerId.childNodes[0].nodeValue);
            }
        }
    },
    error:function (xhr, ajaxOptions, thrownError) {
        alert('xhr.status: ' + xhr.status);
        alert(thrownError);
    }
  });
});

Any Idea please?

Many Thanks

like image 276
Amin Avatar asked Oct 08 '11 19:10

Amin


1 Answers

$.ajax({
    type: "GET",
    getUrl:url,
    ...

should be

$.ajax({
    type: "GET",
    url: url,
    ...

See the docs at http://api.jquery.com/jQuery.ajax/

like image 126
Andbdrew Avatar answered Oct 08 '22 16:10

Andbdrew