tags:

views:

40

answers:

1

High!

I just wondered why this won't work?

$.post($("#jsCheckoutForm_1b").attr("action"), { 
    sLoginName: $("#sLoginName").val(), 
    sPassword: $("#sPassword").val() 
    }, function(sData){
        alert(sData);
    }
);

the fun thing is that if i hard code the action in stead of using $("#jsCheckoutForm_1b").attr("action"), the form is submitting. Alerting $("#jsCheckoutForm_1b").attr("action") does work fine (meaning it displays the right url to use).

Any ideas?

A: 

Your code looks fine. I would cache some variables and test them.

var form=$('#jsCheckoutForm_1b'),
  url=form.attr('action'),
  login=$('#sLoginName'),
  password=$('#sPassword');

console.log(form, url);
form.submit(function(){
  $.post(url,
    {sLoginName: login.val(), sPassword: password.val()},
    function(sData){

  });  
  return false;
});
czarchaic