Reputation: 313
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?
Upvotes: 1
Views: 7073
Reputation: 4540
You may need to have return false;
on the onclick function of the submit button.
Upvotes: 1
Reputation: 6318
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;
});
Upvotes: 0