You’re making a GET type HTTP request, which means specifying a file path is illegal and won’t work.
Therefore, its function is loadXMLDoc will not get another return until you specify an action.
How so?
If you don’t already have it, then create a method for Contact
in your controller Home
. Something like that:
public class HomeController : Controller
{
[...]
public ActionResult Contact(int id)
{
return View(id);
}
}
Then, in your loadXMLDoc function, pass as parameter "/Home/Contact?id=" + valor
, thus:
function RecuperaDados(valor){
loadXMLDoc("/Home/Contact?id=" + valor);
}
What happened? What’s the difference?
GET requests made with AJAX request for an equivalent type return - HTTP, in this case -, and you were dealing with a file address, which, as already said, will not work. So we create an action on your controller Home
, calling for Contact
, to render your view Contact.aspx
(you’ve seen Razor?) as a response to a GET request in the HTTP protocol.
In this way, we were able to solve your problem by meeting the specification of the AJAX request.