Tuesday, 10 September 2013

AJAX GET REQUESTS

AJAX GET REQUESTS

Please help, I'm stuck here. I have a problem with passing input parameter
to my C# controller. I tried really a lot of things I found here, but
still there's some mistake.
Here is code:
var a = $.ajax({
type:"GET",
url: "/Weather1/Weather_get",
data: "location=Paris%",
contentType: 'application/json; charset=utf-8',
cache: false,
success: function (data) {
console.log(data);
}, //succes
error: function (data) {
console.log(data);
}//error
}) //ajax;
And here is controller:
[HttpGet]
public JsonResult Weather_get(String location) etc etc...
Everything I tried gives me input location NULL. I know my controller is
working fine because I get data from it, but I really need that data to be
for specific location, so that's why I need it like this. Also don't want
to change it to POST because this is homework problem so I have to have
both HttpPost and HttpGet in my controller.

No comments:

Post a Comment