Click here to Skip to main content
15,921,884 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

I am trying something using jquery ajax but it is not working .here is my code
JavaScript
if (txtUsername != "" && txtPassword != "") {
            debugger
            $.ajax({
                url: '/../UserData/User.json',
                dataType: 'json',
                success: function (data) {
                    $.each(data, function (obj, item) {
                        if (item.user_name == txtUsername && item.password == txtPassword) {
                            
                            window.location.href = "User/123.aspx?user=" + item.user_id + "";

                        }
                    });
                },
                error: function (data) {
                    alert('ERROR: Please Try Later ! ');
                }
            });
        }
        else {
            document.getElementById("<%=lblIncorrect.ClientID %>").style.display = "block";
        }
        return false;
    });


The if condition is true and it is entering to ajax call but nothing is returning. Directly it comes to return false line. when I debugged can't find any error also.

please help
Posted
Updated 10-May-15 22:28pm
v3
Comments
Afzaal Ahmad Zeeshan 11-May-15 4:30am    
Check for whether the link you've provided is correct or not?
priyadarshini tv 11-May-15 4:31am    
checked.that is correct one
ZurdoDev 11-May-15 13:34pm    
This runs asynchronously so after it calls the ajax it will go to return false. You'll want to change how that works.

And also put a breakpoint on the success function.
priyadarshini tv 12-May-15 1:34am    
Thank you. i fixed the issue :)

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