There is a dropdown in the page. Changing its value will get related data.
The code works when the type is GET
. When I set it to POST
, the parameter value comes as null. why is it so. How should I make this work even when the type is `POST'.
JS:
$(".ddlBrands").change(function () {
getData("GetModels");
});
function getData(methodName) {
$.ajax({
type:"POST",
url: "/handlers/ModelHandler.ashx",
dataType:"json",
data: { 'methodName': methodName, 'brandId':$(".ddlBrands").val() },
success: function (resultSet) {},
error: function (resultSet) {}
});
}
ASHX:
public void ProcessRequest (HttpContext context)
{
context.Response.ContentType = "text/html";
string methodName = context.Request.QueryString["methodName"]; //null when Type is POST
string brandId = context.Request.QueryString["brandId"];
//some more code to get data from DB
}