Reputation: 9184
I have such js:
function get_models(manufacturer_id) {
$.ajax({
url: "/cars/get_models/"+manufacturer_id,
type: "GET",
dataType: "html"
success: function(text) {
$("#model-select").html(text);
}
error: function(){
//alert('Ошибка javascript');
$.ajax(this);
}
});
}
but i get error on line success: function(text) {, and if i change it to success: function(data) or success: function() i still get error: "Uncaught SyntaxError: Unexpected identifier " but why? i didn't imagine why )
Upvotes: 0
Views: 55
Reputation:
$.ajax accept attributes in hash, so you should put values in hash and all the values should be separate with ',' .
you did not put , after
dataType: "html" like dataType: "html",
and
suceess block
success: function(text) {
$("#model-select").html(text);
},
function get_models(manufacturer_id) {
$.ajax({
url: "/cars/get_models/"+manufacturer_id,
type: "GET",
dataType: "html",
success: function(text) {
$("#model-select").html(text);
},
error: function(){
$.ajax(this);
}
});
}
Upvotes: 1
Reputation: 9351
you missed ,
after dataType and success.
change
dataType: "html"
success: function(text) {
$("#model-select").html(text);
}
to
dataType: "html",
success: function(text) {
$("#model-select").html(text);
},
Upvotes: 1