Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About TannerS

  • Rank
  1. Hey! New to these forums, but I just started web dev and about to finish the book. I am having a hard time with one thing. Well, the entire Ajax chapter is hard for me, but one part in particular I don't understand, it is a chunk of code inside the login.js for the section. // Create an object of Ajax options: var options = new Object(); // Establish each setting: options.data = data; options.dataType = 'text'; options.type = 'get'; options.success = function(response) { // Worked: if (response == 'CORRECT') { // Hide the form: $('#login').hide(); // Show a message: $('#results').removeClass('error'); $('#results').text('You are now logged in!'); } else if (response == 'INCORRECT') { $('#results').text('The submitted credentials do not match those on file!'); $('#results').addClass('error'); } else if (response == 'INCOMPLETE') { $('#results').text('Please provide an email address and a password!'); $('#results').addClass('error'); } else if (response == 'INVALID_EMAIL') { $('#results').text('Please provide your email address!'); $('#results').addClass('error'); } }; // End of success. options.url = 'login_ajax.php'; // Perform the request: $.ajax(options); 1) is this line options.success = function(response) suppose to return a boolean value? 2) also on the same line, options.success = function(response), i am having huge problem understanding where response came from. This parameter variable is not declared anywhere or passed in, so where did it come from? 3) options.data = data; options.dataType = 'text'; options.type = 'get'; ...... options.url = 'login_ajax.php'; are these names, (data, dataType, type, and url) always required for ajax? or can this (or ajax in general) be done in different ways? 4) $.ajax(options); can you explain this more? thanks in advance guys!
  • Create New...