Reputation: 313
I want to combine these two function into one. #Ctry,#Yd
are dropdown lists. Please show me the path. Thank you in advance.
$('#Ctry,#Yd').change(function () {
var url = '@Url.Action("tal", "St")'
$('#Rial').load(url, { ctry: $('#Ctry').val(),yd: $('#Yd').val() })
});
$('#Ctry,#Yd').change(function () {
var url = '@Url.Action("tala", "St")'
$('#con').load(url, { ctry: $('#Ctry').val(),yd: $('#Yd').val() })
});
Upvotes: 0
Views: 16
Reputation: 164796
Can't you just use one .change()
handler and just put the two .load()
calls in it with their respective URLs?
$('#Ctry, #Yd').change(function () {
let data = {
ctry: $('#Ctry').val(),
yd: $('#Yd').val()
}
let rialUrl = '@Url.Action("tal", "St")'
let conUrl = '@Url.Action("tala", "St")'
$('#Rial').load(rialUrl, data)
$('#con').load(conUrl, data)
})
Upvotes: 1