Reputation: 2686
I have two sites one is written in asp.net webforms and the other one is written in asp.net mvc 2. I have a page in webforms wich uses jQuery Load to get data from both projects.
Code from the page in asp.net webforms:
$("#divFeedsPorTagMVC").load('http://localhost:50001/InfoMVC/?tag=java', function (){});
$("#divFeedsPorTagWebForms").load('http://localhost:50000/InfoWebForms.aspx?tag=java', function () {}});
Divs in aspx page:
<div id="divFeedsPorTagWebForms" ></div>
<div id="divFeedsPorTagMVC" ></div>
The jQuery call to WebForms works well and fills the "divFeedsPorTagWebForms" with the HTML i need.
The jQuery call to MVC2 enters to the Index function of the InfoMVCController(debug mode), shows that the tag param is being passed well, but doesn´t fill the "divFeedsPorTagMVC" div with the HTML it's suppossed to return.
Any suggestions?
Thanks.
EDIT Controller:
public class InfoMVCController : Controller
{
private ServicioSORSS.ServicioSORSSClient _srvSORSS = new ServicioSORSSClient();
//
// GET: /InfoWebForms/
public ActionResult Index(string tag)
{
return View(_srvSORSS.ObtenerFeedsPorTag(tag));
}
}
If I just copy the URL and paste it in the nav bar of firefox it does return all the data i need!
Upvotes: 0
Views: 1006
Reputation: 6748
You are running into a problem with Same origin policy. You browser isn't allowing the load, because it's coming from a different site.
Look into the standard $.ajax() function, and use jsonp
as the dataType.
It will be something like:
$.ajax({
type: "GET",
url: "http://localhost:50001/InfoMVC/?tag=java",
dataType: "jsonp",
success: function(data){
$('#divFeedsPorTagMVC').html(data);
}
});
Upvotes: 1