Hi Mahesh1986,
I have created sample that full-fill your requirement.
HTML
<div>
<input type="text" value="" id="Name" />
<input type="text" value="" id="age" />
</div>
<div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/json2/20130526/json2.min.js"></script>
<script type="text/javascript">
$(function () {
var obj = {};
obj.fileName = '<%=ResolveUrl("~/Details.json") %>';
$.ajax({
type: "POST",
url: "Default.aspx/GetData",
data: JSON.stringify(obj),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var array = eval(response.d);
$('[id*=Name]').val(array[0].Name);
$('[id*=age]').val(array[0].Age);
},
failure: function (response) {
alert(response.d);
},
error: function (response) {
alert(response.d);
}
});
});
</script>
</div>
Code
[WebMethod]
public static string GetData(string fileName)
{
using (StreamReader sr = File.OpenText(HttpContext.Current.Server.MapPath(fileName)))
{
string json = sr.ReadToEnd();
return json;
}
}
Details.Json
[
{
"Name": "Mahesh",
"Age" : "28"
}
]
Screenshot