Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Oct 2011
    Posts
    113
    Thanks
    9
    Thanked 1 Time in 1 Post

    JQuery stops working after more then 1 action HELP!

    PHP Code:
    $(document).ready(function() {
        $(
    "#createorder").click(function() {
        $(
    "#message2").html("<div class='alert info no-margin top'>Validating order...</div>");
            var 
    action "check.php";
            var 
    form_data = {
                
    delay: $("#delay").val(),
                
    votes: $("#votes").val(),
                
    threads: $("#threads").val(),
                
    sid: $("#sid").val(),
                
    order1
            
    };
            
            $.
    ajax({
                
    type"POST",
                
    urlaction,
                
    dataform_data,
                
    success: function(response)
                {
                
                    if (
    response == '1')
                            $(
    "#message2").html("<div class='alert success no-margin top'>Order has been successfully created!</div>");
                            $(
    "#voteform").slideUp();
                            
                            
                        else if (
    response == '2')
                            $(
    "#message2").html("<div class='alert error no-margin top'>You do not have enough credits to order.</div>");
                        else if (
    response == '3')
                            $(
    "#message2").html("<div class='alert error no-margin top'>Your thread count has exceeded the limit.</div>");
                        else if (
    response == '4')
                            $(
    "#message2").html("<div class='alert error no-margin top'>Your vote count has exceeded the limit.</div>");
                        else if (
    response == '5')
                            $(
    "#message2").html("<div class='alert error no-margin top'>Your delay count has exceeded the limit.</div>");    
                        else if (
    response == NULL)
                            $(
    "#message2").html("<div class='alert error no-margin top'>Something went terribly wrong , please contact support!</div>");
                    
                    
                } 
            });
            
            return 
    false;
        });
                    
        }); 
    Hello,

    See where it says
    $("voteform").slideUp;

    That is causing the jQuery to stop working,
    it's not just that if I put more then 1 line after success it stops working
    I tried to alert them after the notification and it doesn't work , but if it's just the notification box it will work...
    Last edited by Vernk; 01-27-2013 at 01:29 AM.

  • #2
    Senior Coder DanInMa's Avatar
    Join Date
    Nov 2010
    Location
    Salem,Ma
    Posts
    1,577
    Thanks
    13
    Thanked 248 Times in 248 Posts
    try using proper syntax for the if else's

    Code:
    if (1==1){
    //do something
    }
    else if (1==2) {
    //do something else
    }
    else if (1==3) {
    //do something
    }
    else {
    d/do soemthign if no other value is met
    }
    alos you should change the first line from

    Code:
      $("#createorder").click(function() {
    to this

    Code:
      $("#createorder").click(function(e) { 
    e.preventDefault();
    and remove the return false
    Last edited by DanInMa; 01-27-2013 at 12:53 AM.

  • #3
    Regular Coder
    Join Date
    Oct 2011
    Posts
    113
    Thanks
    9
    Thanked 1 Time in 1 Post
    Hello,

    Thanks for the help.
    It looked like the if else were the problem
    It is working now

    Thanks!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •