tabalinas / jsgrid

Lightweight Grid jQuery Plugin
http://js-grid.com
MIT License
1.52k stars 352 forks source link

Uncaught TypeError: $.ajax is not a function while inserting using insert control #1297

Open akambaram opened 4 years ago

akambaram commented 4 years ago

addinfo:253 Uncaught TypeError: $.ajax is not a function

at Object.insertItem (addinfo:253)
at Grid._controllerCall (jsgrid.core.js:1026)
at Grid.insertItem (jsgrid.core.js:1278)
at jsgrid.field.control.js:182
at HTMLInputElement.<anonymous> (jsgrid.field.control.js:212)
at HTMLInputElement.dispatch (jquery-1.8.3.js:3058)
at HTMLInputElement.eventHandle (jquery-1.8.3.js:2676)

image

js code:

insertItem : function(item) {

                    var d = $.Deferred();

                    $.ajax({
                      method: "POST",
                      url: "/AHSS/insertproducts",
                      data: item,
                      dataType: "json",
                      contentType: "application/json; charset=utf-8"
                    }).done(function(idata) {
                        //sconsole.log( "done:" + JSON.stringify(data) );
                        debugger
                        var ida = {
                                data : idata,
                                itemsCount : idata.length
                            }
                        d.resolve(ida);
                    }).fail(function( msg ) {
                        console.log( "fail" + msg );
                        d.reject();
                    });

                    return d.promise();
} 

Fields info:

fields : [ { name : "pcode", title : "Product Code", type : "text", width : 50, validate : "required", align : "center" }, { name : "pname", title : "Prodcut Name", type : "text", width : 150, validate : "required", align : "center" }, { name : "pstatus", title : "Status", type : "select", items : statuses, align : "center" }, { type : "control" } ]

akambaram commented 4 years ago

Uncaught TypeError: $.ajax is not a function at Object.insertItem (addinfo:265) at Grid._controllerCall (jsgrid.core.js:1026) at Grid.insertItem (jsgrid.core.js:1278) at jsgrid.field.control.js:182 at HTMLInputElement. (jsgrid.field.control.js:212) at HTMLInputElement.dispatch (jquery-3.4.1.min.js:2) at HTMLInputElement.v.handle (jquery-3.4.1.min.js:2)

Hello Experts,

Your kind inputs are highly appreciated.

Thanks in advance.

Bhanu

assadnazar commented 4 years ago

check whether you added jquery library before jsgrid and then try something like this insertItem: function(item) { return $.ajax({ type: "POST", url: "url", data: item }); },