I have a javascript function which returns a value that I am trying to display in a table in my partial view.
In my main view I have something like this:
<script type="text/javascript">
function myFunc(i)
{
var url = '/myurl/?id=' + i;
$.getJSON(url)
.done(function (data)
{
return data;
}
}
</script>
In my partial view html I am trying to do this:
<td><script>document.write(myFunc())</script></td>
The function gets called but it seems to always return undefined am I doing something wrong here?
<td><script>window.myFunc();</script></td><script>var data = window.myFunc(); console.log(data); </script></td>windowobject in your partial view. Please check<script>console.log(window); </script>Please check whether you're getting your function here ?