Having trouble setting up a website for my wedding. Hope someone can find out what the problem is before the big day :)
The following code is working on my dev machine but once I publish it to my server, it does the postback and then imediatly after performs a GET request. The GET request should not happen.
I've got some basic set up code
$.ajaxSetup({
beforeSend: function (xmlHttpRequest) {
//Used by the server to determine an async request
xmlHttpRequest.setRequestHeader('X-Requested-With', 'jQuery');
$.blockUI({ message: '<h3>Please wait...</h3>' });
},
complete: function (XMLHttpRequest, textStatus) {
$.unblockUI();
}
});
And here is the code that binds to the anchor tag. Note that I've also tried this on button and input elements with no luck.
$('.basket-btn').click(function (src) {
src.preventDefault();
var form = $(src.target).closest('form');
/* If the form contains validatable elements, then set this to false so the validation function is triggered. */
var doWeValidate = !form.find('span[id$=_validationMessage]').length > 0;
if (doWeValidate || !Sys.Mvc.FormContext.getValidationForForm(form[0]).validate('submit').length) {
var destination = $(src.target).attr('data-destination');
$.post(form.attr('action'), form.serialize(), function (data) {
$("#" + destination).html(data);
});
}
});
Here is my site if you want to see the problem I'm talking about.
http://www.vinceandjeanswedding.com/GiftRegistry/
If you enter an amount and click contribute, it will perform a postback and then (according to firebug) a GET request will follow straight after.
Please help me.