Click here to Skip to main content
15,907,149 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, I have design a window form application, in which I call a jQuery. The script is following

C#
<script type="text/javascript">
        var email;
        var pwd;
        function loginuser(email, pwd) {

            var query = 'aUserName=' + email + '&aPassword=' + pwd;

            function makeRequest(url) {

                if (window.XMLHttpRequest) {

                    httpRequest = new XMLHttpRequest();

                }
                else if (window.ActiveXObject) {
                    try {

                        httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
                    }
                    catch (e) {
                        try {
                            httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        catch (e) { }
                    }
                }

                if (!httpRequest) {

                    alert('Giving up :( Cannot create an XMLHTTP instance');
                    return false;
                }
                httpRequest.onreadystatechange = alertContents;

                httpRequest.open('GET', url);

                httpRequest.send();

            }




            function alertContents() {


                if (httpRequest.readyState === 4) {
                    if (httpRequest.status === 200) {
                        alert(httpRequest.status);
                        //httpRequest.open("GET", window.location.href, false);
                        //httpRequest.responseType = "document";
                        // httpRequest.send();

                        if (httpRequest.response) {
                           
                            var info = JSON.parse(httpRequest.response);

                            if (info.Error) {

                                alert("Request cannot be completed this time. Please try again later.");
                                loader("unlock");
                            }
                            else {
                                checkCookie();
                            }
                        } else {
                            console.log("ignoring null value");
                            alert("Request cannot be completed this time. Please try again later.");
                        }
                    }
                    else {
                        alert('There was a problem with the request.');
                    }
                }
            }

            makeRequest('http://dev.livestuff.com/.LoginAsJSON?' + query);

        }
    </script>



The control is not going inside the if(httpRequeset.Response) condition and when I print it through alert, it showing undefined alert. It may be the problem of cross domain but I am not understanding properly. So what I have to do for this where I have to change.


Thanks.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900