CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   JavaScript frameworks (http://www.codingforums.com/forumdisplay.php?f=62)
-   -   Resolved JQuery stops working after more then 1 action HELP! (http://www.codingforums.com/showthread.php?t=286502)

Vernk 01-27-2013 12:31 AM

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...

DanInMa 01-27-2013 12:47 AM

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

Vernk 01-27-2013 01:28 AM

Hello,

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

Thanks!


All times are GMT +1. The time now is 03:38 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.