Very simple AJAX request, but it's not working at all. Getting this error i've never seen before:
Cannot read property 'mode' of undefined
$.ajax({
url: '/Contractor/api/plot/LinkBuyer',
method: 'POST',
data: {
'buyerId': 1,
'plotId' : parseInt(sPlotId, 10),
'activateDirectly': true
},
success: function (data) {
console.log('success');
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(JSON.stringify(jqXHR));
console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
}
});
To solve the "Cannot read properties of undefined" error, make sure that the DOM element you are accessing exists. The error is often thrown when trying to access a property at a non-existent index after using the getElementsByClassName() method.
What Causes TypeError: Cannot Read Property of Undefined. Undefined means that a variable has been declared but has not been assigned a value. In JavaScript, properties and functions can only belong to objects.
To fix Error: TypeError: Cannot read property '…' of undefined with Angular, we should make sure the variable we're rendering is defined. to use the safe navigation operator if foo and bar are objects. We use arr && arr. length > 0 to make sure arr is defined and it has length bigger than 0.
The "Cannot read property 'click' of null" error occurs when trying to call the click method on a null value. To solve the error, run the JS script after the DOM elements are available and make sure you only call the method on valid DOM elements.
Got the answer! I was using the slim version of jquery...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With