I am getting the error "SyntaxError: Invalid shorthand property initializer" in my Chrome console, after writing this code of javascript/jquery
var i = 1; $(document).on('click', '.AddMoreaddress', function () { $.get('/Mpa/Company/Addreses', { Id=i}, function (data) { i++; $("#Addmore").append(data); }) })
Before writing this code on the page, I wasn't getting any error and it was working fine, so what's the issue in this and how can I resolve it?
thanks
Because it is not correct way of assigning value in jQuery-javascript, you need to assign value using
:
instead of =
, So your code should be like this
var i = 1;
$(document).on('click', '.AddMoreaddress', function () {
$.get('/Mpa/Company/Addreses', { Id=i}, function (data) { // here Id:i instead of Id=i
i++;
$("#Addmore").append(data);
})
})
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly