I was working on some code, and cant seem to see why this is always failing. I had tried to debug it, but the asp page is is referencing will not hit a breakpoint. (Hint maybe that it isnt fetching the page??). for the data: part i had it right before the post trying to see if it would do JSON.stringify({variables}) to see if that worked as well, but it did not
Is there something that I am doing wrong here?
$.ajax({
type: 'POST',
url: 'AutoComplete.asmx/getWebFormDesignFieldContents',
data: {
'fe_name': "*",
'count': 200, //this might need to be adjusted slightly. I may want to make it more OR less.
'also_search_fe_desc': true,
'opts': opts
},
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (result) {
//success
$("div.modal").replaceWith($(result));
$("div.modal").fadeIn();
},
error: function (result) {
//error
//alert("Error: "+result.statusText);
$("div.overlay").fadeOut();
}
});
On the serverside portion of ASP I have:
public String getWebFormDesignFieldContents(String fe_name, int count, bool also_search_fe_desc, String opts)
{
String retValue = "";
...
return retValue;
}
You need to decorate your method with
[WebMethod]attributeSomething else you need to change is your json format. You have to pass a string.
You could use
JSON.stringifybut take into account that old browsers don’t have support for it so you may need to handle that situation.You’ll also need to work on your return logic. For now I just see you return an empty string. If you show more code we could help you with that too.