With reference of this question, this is how solved this without a function.
Now I have a function and I try to call in javascript and also try to call that data in alert box but the alert box does not populate. My code is this:
$('#submitchart').click(function() {
//alert("i");
var webmethod = 'WebForm1.aspx/Jqufunc';
$.ajax({
type: 'POST',
url: webmethod,
data: JSON.stringify({
yearP: $('#yearValue').val()
}),
contentType: 'application/json;charset=utf-8',
dataType: 'json',
success: function(response) {
debugger;
alert(JSON.stringify(response.d));
var data1 = response.d.split('*')[0];
var data2 = response.d.split('*')[1];
alert(data1);
alert(data2);
},
error: function() {
debugger;
alert(data1);
alert(data2);
}
});
});
function Loadchart() {
$('#submitchart').click();
};
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<form id="form1" runat="server">
<asp:DropDownList ID="yearValue" runat="server" AutoPostBack="True" ViewStateMode="Enabled"></asp:DropDownList>
<button id="submitchart" runat="server">Show Chart</button>
<div id="container" style="width: 100%; height: 400px;"></div>
</form>