0
$(document).ready(function(){
  $(".submit").click(function() {

    var emailVal = $(".email").val()

    $.ajax({ type: 'POST',
             url: 'settings/update',
             data: { email: emailVal },
             beforeSend:function(){

                //loading image
                $('#ajax-panel').html('<div class="loading"><img src="/images/ajax-loader.gif" alt="Loading..." /></div>');

             },
             success:function(data){

                 // successful request; do something with the data
                 $('#ajax-panel').empty();

                 $('#ajax-panel').html(data);     

             },
             error:function(){

                 // failed request; give feedback to user
                 $('#ajax-panel').html('<p class="error"><strong>Oops!</strong> Try that again in a few moments.</p>');
             }
          });
        });
      });

The emailVal variable is not getting sent as post data. Is there something wrong with my syntax?

6
  • Are you getting any JavaScript errors? Commented Nov 4, 2011 at 20:59
  • Does your URL url: 'settings/update', go to an actual file? Commented Nov 4, 2011 at 21:00
  • 1
    @Biotox... why would it have to go to a file? what if he is using an MVC pattern with URIs. Commented Nov 4, 2011 at 21:03
  • Yes it does, I'm using firebug to debug... it keeps saying success but it's storing it as the string emailVal (regardless of whats in the textbox) ... but when I change the parameter to emailVal2 it says undefined variable Commented Nov 4, 2011 at 21:05
  • 1
    Can we see the HTML for your textbox ? Also why are you referencing it by class and not ID ? Commented Nov 4, 2011 at 21:18

1 Answer 1

1

Missing a semi-colon at the end of this line.

var emailVal = $(".email").val()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.