Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
11
Reply
Ajax section are not working
Ashish Pandey
Jan 17 2018 1:26 AM
277
Reply
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>
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
11
)
Next Recommended Forum
Select items in multiselect dropdown list MVC3 jquery
click on the get route error uncaught refrence error :google