TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ashish Pandey
1.4k
351
8k
Ajax section are not working
Jan 17 2018 1:26 AM
plz help
<script type="text/javascript">
$(document).ready(function() {
var ddlCountry = $('#ddlCountry');
var ddlport = $('#ddlport');
alert("demo");
$.ajax({
type: "POST",
url: "/webmethoddemo.aspx/GetCountry",
data: $(this).serialize(), //have also tried "{}" and other options such as removing the line
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(data) {
alert("success");
var result = jQuery.parseJSON(data.d)
ddlCountry.append($("<option></option>").val(0).html('--Select--'));
$.each(result, function(index, value) {
ddlCountry.append($("<option></option>").val(value.CountryName).html(value.VCOUNTRYCODE));
});
},
error: function(data) {
alert("error");
}
});
// to bind sate
$('#ddlCountry').change(function() {
var selectedValue = $('#ddlCountry option:selected').val();
if (selectedValue != "0") {
var VCODE = $(this).val();
$.ajax({
type: 'POST',
contentType: 'application/json',
data: "{VCOUNTRYCODE:'" + VCODE + "'}",
url: 'webmethoddemo.aspx/GetPort',
dataType: "json",
success: function(data) {
alert('success')
var result = jQuery.parseJSON(data.d)
ddlport.append($("<option></option>").val(0).html('--Select--'));
$.each(result, function(index, value) {
ddlport.append($("<option></option>").val(value.PortCode).html(value.PortName));
});
},
error: function(data) {
alert("error");
}
});
}
});
});
</script>
Reply
Answers (
11
)
Select items in multiselect dropdown list MVC3 jquery
click on the get route error uncaught refrence error :google