I want to use MVC3 to generate content for a “widget” to be usable by another site. How can I use Javascript/Jquery to do this? so for example a client will have in their page:
<div id="widget_div">
<script type="text/javascript">
<--Call JQuery here to get content from MVC3 site and inject into "widget_div"-->
</script>
</div>
Are there examples etc…
Thanks
You could use JsonP. Make a call to the MVC website that would return a javascript snippet along with the data, you use that data and render it into your widget.
Suppose your MVC site would return javascript with json data something like
callback({ Name : “Firstname” , Age: “25” } );
and your widget will need to make a jsonp call with that callback function, when the site returns the data, it will invoke the callback function where you handle the data and render the widget.