i'm using this code to get a partial view from the server ot put it in a div
$.ajax(
{
type: "POST",
url: "MyControler/MyAction",
success: function (result) {
$('#partialView').html(result);
},
error: function (req, status, error) {
alert("Coudn't load partial view");
}
});
now i would like to do the same thing but i'd call a simple methode returning a string and put the result in a textbox
$.ajax(
{
type: "POST",
url: "MyControler/MyMethod",
success: function (result) {
$('#myTextBox').html(result);
},
error: function (req, status, error) {
alert("Coudn't load partial view");
}
});
the methode would be like that
public string MyMethod()
{
returning "hello";
}
obviously it doesn't work but is there a way to make it work ?? is there an attribute i should use for the methode
thanks in advance
ps:
from what i red in the first answer i tried this but it doesn't work
public ActionResult Hello()
{
return Content("Hi there!");
}
is there something wrong with the ajax call ??
$.ajax(
{
type: "POST",
url: "MyControler/Hello",
success: function (result) {
$('#myTextBox').html(result);
},
error: function (req, status, error) {
alert("Coudn't load partial view");
}
});
ps
I wanted to try on a clean project and it worked fine using a simple method returning a string
since it worked i tried to implement it to my project but it seems it only works from the starting page set up in the global.asax file any idea what i should do to make it work in every pages ???