Why when I click on the update button error TypeError: r is undefined happen?
11,935
The reason for this is because your datasource's update method is being called. It has not been set which gives you the TypeError
.
You can do one of two things.
- Set the update method of your datasource to contain the logic contained in your save function. You'll need to set update as a function in order to be able to control the method dynamically (POST/PUT). You should remove the ajax code from the save event at this point.
- Set the update method to a dummy function and handle it as part of the save event instead.
Here's an example of approach #2.
var dataSource = new kendo.data.DataSource({
..
update: function(e) { return true; }
..
});
Keep the save event function as is.
Note that I'm getting an Uncaught SyntaxError: Unexpected number
error. I believe this is originating from the LastClientsCount
property.
Fiddle: http://jsfiddle.net/mSRUe/23/
Author by
object json
Updated on June 17, 2022Comments
-
object json about 2 years
The error in firefox browser as follows: TypeError: r is undefined
This is the chrome browser: Uncaught TypeError: Cannot read property 'data' of undefined
I also did a video for a better understanding.
The error occurs when I changed the values in a field
button code update
save: function (e) { var that = this; $.ajax({ url: '/api/apdevice', type: e.model.id == null ? 'POST' : 'PUT', contentType: 'application/json', data: JSON.stringify(e.model), success: function (data) { alert('yes'); that.refresh(); }, error: function (data) { alert('no'); that.cancelRow(); } }); }