MapSVG Plugin with undefined is not a function (near ‘….success(function(data){…’)

Inspect Element from Chrome

I have 2 separate projects using MapSVG plugin. however, on the other project it keeps displaying this error which it puzzled me how was the error occurred to the site which there’s is no difference from the file neither configurations that I am applying.

Here’s what the browser find:

While I tried to sneak down to the code, and it seems fine to me.

MapSVGDatabaseService.prototype.getAll = function(params){
    var _this = this;

    // if table isn't created yet then return empty array
    if(!this.tableName){
        defer = $.Deferred();
        var obj = [];
        defer.promise();
        defer.success = defer.done;
        defer.resolve([]);
        return defer;
    }

    params = params || {};
    var filters = params.filters || null;
    this.page = params.page? parseInt(params.page) : this.page;
    var perpage = params.perpage? parseInt(params.perpage) : this.perpage;
    var search = params.search;
    var searchField = params.searchField;
    return $.get(ajaxurl, {
        action: 'mapsvg_data_get_all',
        search: search,
        searchField: searchField,
        filters: filters,
        page: this.page,
        sortBy: this.sortBy,
        sortDir: this.sortDir,
        perpage: perpage,
        map_id: this.map_id,
        table: this.table
    }, null, 'json')
        .success(function(data){ //**This is where error caught by inspect element**//
            if(data){
                _this.hasMoreRecords = _this.perpage && (data.length > _this.perpage);
                if(_this.hasMoreRecords){
                    data.pop();
                }
                _this.rows = _this.formatData(data);
            }else{
                _this.hasMoreRecords = false;
                _this.rows = [];
            }

            _this.reindex();
            _this.trigger('dataLoaded');
        });
};

What could possibly the cause of this issue?

Read more here: MapSVG Plugin with undefined is not a function (near ‘….success(function(data){…’)

Leave a Reply

Your email address will not be published. Required fields are marked *