0
votes

The following code snippet results in a javascript error pointing at the line 'fail: function()' The error is: Uncaught SyntaxError: Unexpected identifier and also fails in Firefox

        $.ajax(
                    {
                        type:"post",
                        url: "http://hdkumdo.com/gumdo/manage_members/view",
                        data:{ email:email},
                        done:function(response)
                        {
                            console.log('Done' + response);
                        }
                        fail: function() 
                        {
                            console.log('Failed');
                        }
                    }); 

The full function below works when the ajax code is commented out:

  $( ".row_button" ).click(function() {
       var email= "hello" ;           
       $('#membertbl').find('tr').click( function(){
          var ID = $(this).find('td:first').text();
          console.log('You selected ID: ' + ID);

/*      $.ajax(
                {
                    type:"post",
                    url: "<?php echo base_url(); ?>manage_members/view",
                    data:{ email:email},
                    done:function(response)
                    {
                        console.log('Done' + response);
                    }
                    fail: function() 
                    {
                        console.log('Failed');
                    }
                }); */
     });
});
1
done:function(response) { ... } ,. <-- comma missing - Adelin

1 Answers

1
votes

You're missing a comma in your properties list.
Also there is no fail and done config properties in jQuery ajax, what you're looking for is success and error

    $.ajax(
                {
                    type:"post",
                    url: "http://hdkumdo.com/gumdo/manage_members/view",
                    data:{ email:email},
                    success:function(response)
                    {
                        console.log('Done' + response);
                    },
                    error: function() 
                    {
                        console.log('Failed');
                    }
    });