i have the following jQuery function in my project
$.ajax({
url: "WebServices/BrowserType.asmx/IsIE",
contentType: "application/json; charset=utf-8",
dataType: "text",
type: "POST",
data: {},
success: function (msg) {
If(msg.d== 'false')
{
$("#Test2").html(msg);
}
},
error: function (err) {
alert("Error" + err.toString());
}
});
What i intend to do is to get a boolean value from my webservice and then act on the result on my jquery success option.
I had tried the following:
I set the dataType to boolean (of course, i changed my method return type to bool) and in the success function of the jquery, i had
success:function(){if (msg.d){$("#Test2").html(msg);}}
but an error was thrown. (Object. That's the error.)
- I tried setting the dataType to text (this time i changed my method return type to string) and in the success function of the jquery, i did it as in the above main code. This time there was no error but the success function seems not to work. However, when i removed the If statement from the above code, the success code worked.
Please how do i go about this. I had tried what i know. I intend to act on a boolean value. My web service returns either true or false and i want to act on the boolean value returned. The issue is how can i determine if the value returned is true or false in the success function of my ajax?
Your contribution is highly appreciated. I have edited this post to make it clearer.