I have a simple function in my web service.
` [WebMethod]
public string TryWB()
{
string sMsg = "try";
return sMsg;
} `
and I am calling it from my aspx page..
at the top i have tried
[ScriptMethod( ResponseFormat= ResponseFormat.Json)]
(or .xml or even httpget)
and in the function also I have tried serialising it with
sMsg = (new JavaScriptSerializer()).Serialize(sMsg);
or even made custom object just to wrap message and even tried
JsonConvert.SerializeObject(cm,Newtonsoft.Json.Formatting.Indented);
From my aspx pages all combinations of text, xml, json made
$.ajax({
URL: 'FLMSWebService/Login.asmx/TryWB',
method:"POST", (get also tried)
contentType: "application/json; charset=utf-8",
dataType: "text",
success: function (data) {
alert('success');
alert(JSON.stringify(data));
},
error: function (jqXHR, exception) {
alert(jqXHR.responseText);
}});
contentType: json, xml tried
datatype : xml , json tried...
in web.config also
and
this is all i got from my 2 day search on net...but main point if i have
dataType: "text",
its a success and full page returned as data
in every other datatype or contenttype i get error
and the full page is shown in
alert(jqXHR.responseText);
in the error callback
I am stuck!! please help
Laxmidhar SahooPosted Mar 2, 2018, 8:58 PM