Hi, on my page I've to check if the UserName is available and sponsor code is correct. For that I'm using ajax call for both.
Can anyone helps on this? Why they are not giving separate results?Code:Sponsor User Name <span id = "mesg"></span><asp:TextBox ID="txtSpUserName" runat="server" CssClass="DropText" onblur ="ShowAvailability()"></asp:TextBox> Login Name <span id="Login"></span><asp:TextBox ID="txtLoginName" runat="server" CssClass="DropText" onblur ="ShowLoginName()"></asp:TextBox> Script in head tag <script type = "text/javascript"> function ShowAvailability() { $.ajax({ type: "POST", url: "NewJoin.aspx/CheckUserName", data: '{userName: "' + $("#<%=txtSpUserName.ClientID%>")[0].value + '" }', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (response) { alert(response); } }); } function OnSuccess(response) { var mesg = $("#mesg")[0]; mesg.style.color = "#06536e"; mesg.innerHTML = response.d; switch (response.d) { case "true": mesg.style.color = "green"; mesg.innerHTML = "Available"; break; case "Sponsor Not found": mesg.style.color = "red"; mesg.innerHTML = "Sponsor Not found"; break; case "error": mesg.style.color = "red"; mesg.innerHTML = "Error occured"; break; } } function OnChange(txt) { $("#mesg")[0].innerHTML = ""; } </script> Works fine for single ajax call but if I write another call then it updates the second span only <script type = "text/javascript"> function ShowLoginName() { $.ajax({ type: "POST", url: "NewJoin.aspx/CheckUsers", data: '{userName: "' + $("#<%=txtLoginName.ClientID%>")[0].value + '" }', contentType: "application/json; charset=utf-8", dataType: "json", success: OnSuccess, failure: function (respcode) { alert(respcode); } }); } function OnSuccess(respcode) { var logs = $("#Login")[0]; logs.style.color = "#06536e"; logs.innerHTML = respcode.d; switch (respcode.d) { case "true": logs.style.color = "green"; logs.innerHTML = "Available"; break; case "Sponsor Not found": logs.style.color = "red"; logs.innerHTML = "Sponsor Not found"; break; case "error": logs.style.color = "red"; logs.innerHTML = "Error occured"; break; } } function OnChange(txt) { $("#Login")[0].innerHTML = ""; } </script>




Reply With Quote
