How to implement file upload in jqGrid using dataProxy from http://jqgrid-php.net below?
Running code below causes exception
Unable to get value of the property 'removeAttr': object is null or undefined
at line
$(this).data('name', $(this).attr('name')).removeAttr('name');
as show in comment in code.
It looks like ele (form) contains elements without name which causes this exception.
How to fix this code ?
How to change this code so that it loops (saves/restores name) only over elements which have name.
var dataProxyAjax = function (opts, act) { // from http://jqgrid-php.net
opts.url = $(this).getGridParam('url');
//use normal ajax-call for del
if (act.substring(0, 4) == 'del_') {
$.ajax(opts);
}
opts.iframe = true;
var $form = $('#FrmGrid_' + $(this).getGridParam('id'));
var ele = $form.find('INPUT,TEXTAREA').not(':file');
//Prevent non-file inputs double serialization
ele.each(function () {
// todo: how to fix the error: Unable to get value of the property 'removeAttr': object is null or undefined
$(this).data('name', $(this).attr('name')).removeAttr('name');
});
//Send only previously generated data + files
$form.ajaxSubmit(opts);
//Set names back after form being submitted
setTimeout(function () {
ele.each(function () {
$(this).attr('name', $(this).data('name'));
});
}, 200);
};
you are trying to set the value of something that isnt a value. removeAttr just removes the attr…it seems like you are trying to set the data of ‘name’ for (this) element to be equal to (this) but with the attr ‘name’ removed. I’m not sure that makes a lot of sense.
try: