I am doing an ajax call from my javascript to an aspx page's webmethod. The string I'm returning is wrapped in double-quotes for some reason. I tried stripping them out, but the replace only replaced the first one for some reason. There are no quotes wrapping the string on the server-side.
var req = new XMLHttpRequest();
var url = document.URL;
// strip pound sign off the end
var poundIndex = url.lastIndexOf('#');
if (poundIndex === url.length - 1) {
url = url.substring(0, poundIndex);
}
url += '/SignOn';
req.open('post', url, false);
req.setRequestHeader('Content-Type', 'application/json; charset=utf-8');
req.send();
var serverResponse = req.responseText.replace('"', '');
This is what I'm doing on the server:
Return System.Configuration.ConfigurationManager.AppSettings("url").ToString + "?token=" + HttpContext.Current.Session("Token").ToString() + "&aid=ca"
Any ideas?