In view page
<script>
@ViewBag.scripCall
function IPDetction()
{
$.getJSON("http://ip-api.com/json/?callback=?", function (data) {
var items = [];
$.each(data, function (key, val) {
if (key == 'city') {
alert("DetectedCityName=" + val);
}
if (key == 'region') {
alert("DetectedRegionName=" + val);
}
});
});
}
</script>
In Controller
public ActionResult Index()
{
ViewBag.Message = "My MVC APP";
ViewBag.scripCall = "IPDetction();";
return View();
}
Add above code in correct action in controller.
i am already tried this In but not working.I have send a file.In this file "
function IPDetction()
{
$.getJSON("http://ip-api.com/json/?callback=?", function (data) {
var items = [];
$.each(data, function (key, val) {
if (key == 'city') {
alert("DetectedCityName=" + val);
}
if (key == 'region') {
alert("DetectedRegionName=" + val);
}
});
});
}"
this function can be called from mvc Action Result .... so please tell me how it is possible..


0 comments:
Post a Comment
Note: only a member of this blog may post a comment.