Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi, i am doing login with ajax json, web method in asmx file.

in local host its working fine.bt when i am uploaded it online. then its going to error part of ajax. and showing "Undefined" as a error message.

code bellow i have used.

JavaScript
function login() {
            $("#btnLogin").attr("disabled", "disabled");
            $('.loading_login').show();
            var email = document.getElementById("txtLoginEmail").value;
            var password = document.getElementById("txtLoginPassword").value;


            if (email == "" || password == "") {
                alert('Fill up data');
                $('.loading_login').hide();
                return;
            }
            else {

                /* send the link to fetch details */
                var input = email + " " + password; /* detect by space */

                $.ajax(
                {
                    type: 'POST',
                    url: 'ChangePassword.asmx/Login',
                    data: '{\'inputText\':\'' + input + '\'}',
                    dataType: 'json',
                    contentType: 'application/json; charset=utf-8',
                    success: function (response) {
                        if (response != null && response.d != null) {
                            alert('done');
                            if (response.d != "Success") {
                                $("#btnLogin").prop("disabled", false);
                                alert('Wrong email & password !');
                                $('.loading_login').hide();
                            }
                            else {
                                $("#btnLogin").prop("disabled", false);
                                window.location = "home.aspx";
                                alert('welcome');
                                $('.loading_login').hide();
                            }
                        }
                    },
                    failure: function (response) {

                        $("#btnLogin").attr("disabled", "disabled");
                        alert('Sorry! Operation failed.');
                        alert(response.d);
                        $('.loading_login').hide();
                    },
                    error: function (response) {

                        $("#btnLogin").attr("disabled", "disabled");
                        alert('Sorry! Error.');
                        alert(response.d);
                        $('.loading_login').hide();
                    },
                    
                });
                
            }
            clearAll();
        }


please say where is the error...

thanks
Posted
Comments
Bh@gyesh 1-May-14 8:35am    
Hi Arkadeep,
Here we need to check your service is calling or not? means so call messagebox or something which can sure us function is calling.
If it successfull, then there must be some issue in mail sending.

Regards,
Bhagyesh
ZurdoDev 1-May-14 8:38am    
If it works on localhost but on hosted chances are the url is invalid and you'll need to specify the full path, not just the relative path. But it would help to know the exact error and which line of code causes the error.
Arkadeep De 1-May-14 9:17am    
i have given
url: 'http://abc.com/ChangePassword.asmx/Login',

in asmx file change the namepace with my site name..

did all the msg box testing..entering into ajax bt going to error part..
ZurdoDev 1-May-14 10:28am    
1. Hover over the message you and click reply so that the user is notified.
2. We need to know what line of code is causing the error and the exact error.
Arkadeep De 1-May-14 12:41pm    
after this line of executing..
var input = email + " " + password; /* detect by space */

its directly go to

error: function (response) {

$("#btnLogin").attr("disabled", "disabled");
alert('Sorry! Error.');
alert(response.d);
$('.loading_login').hide();
},

only when the project is online. and as a error its showing "Undefined". bt when it is off line its working fine.


i'm also attaching the asmx file...the full code..from that code its calling login()

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class WebService1 : System.Web.Services.WebService
{
[WebMethod(EnableSession = true)]
public string Login(string inputText)
{
int i = 0;
string[] ip = inputText.Split(' ');

User_BLL obj = new User_BLL();
DataTable dt = obj.Login_BLL(ip[0].ToString(), ip[1].ToString());

i = dt.Rows.Count;

if (i >= 1)
{
UserCredential_BLL obj_c = new UserCredential_BLL();
obj.LoginHistory_BLL(ip[0].ToString(), obj_c.GetIP().ToString(), obj_c.GetOs().ToString(), "");
SetSessionAndCookies(ip[0].ToString(), ip[1].ToString());
return string.Format("{0}", "Success");
}
else
return string.Format("{0}", "Wrong email & password !");
}
}


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