Note that there are some explanatory texts on larger screens.

plurals
  1. POActing on a boolean value in an Ajax jQuery call in ASP.NET
    text
    copied!<p>i have the following jQuery function in my project</p> <pre><code>$.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()); } }); </code></pre> <p>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.</p> <p>I had tried the following:</p> <ul> <li><p>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</p> <pre><code>success:function(){if (msg.d){$("#Test2").html(msg);}} </code></pre></li> </ul> <p>but an error was thrown. (Object. That's the error.)</p> <ul> <li>I tried setting the dataType to <strong>text</strong> (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 <strong>If</strong> statement from the above code, the success code worked. </li> </ul> <p>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? </p> <p>Your contribution is highly appreciated. I have edited this post to make it clearer.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload