0

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');
                    }
                }); */
     });
});
user1988589
  • 45
  • 1
  • 1
  • 6

1 Answers1

1

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');
                    }
    }); 
Musa
  • 96,336
  • 17
  • 118
  • 137
  • Many thanks to Musa and Adelin. Re done and fail..I derived that from https://stackoverflow.com/questions/20597445/jquery-ajax-done-callback-not-firing but thanks for the info. – user1988589 Jul 16 '18 at 12:42
  • `done` and `fail` is chained to `$.ajax`, i.e. `$.ajax().done().fail()` and not a property – Musa Jul 16 '18 at 12:52