0

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!

5
  • Have you tried using something like HttpFox or Fiddler or some other tool to see what response you're getting? Commented Apr 6, 2012 at 19:47
  • What do you get if you just load http://localhost:50001/InfoMVC/?tag=java in a browser? Commented Apr 6, 2012 at 19:48
  • Can you post the controller code for the MVC action method that you are calling? Commented Apr 6, 2012 at 19:49
  • updated my question to answer all your questions! Commented Apr 6, 2012 at 19:54
  • I think that the issue is that the webforms app does not know how to handle the ActionResult and you may need to return the result as a string. Commented Apr 6, 2012 at 20:00

1 Answer 1

1

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);
    }
});
Sign up to request clarification or add additional context in comments.

1 Comment

have to tell you i didn´t know anything about this! and you´re right, that was my problem! i can´t use $.ajax because i´m doing a research about jquery load! i ended up publishing each site inside localhost this way: localhost/webforms and localhost/mvc and that way i can call the jquery load without any problems! Thanks for your help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.