this is how i did it recently. It seems to work very well. I mixed up with a bunch of these various jQuery deduplication tools until finally I realized that barbecue is simply the best.
$("form").live('submit',function(event){
event.preventDefault();
var url = $.bbq.getState( "url" );
$.ajax({
url: url,
error: function(XMLHttpRequest, textStatus, errorThrown) {
error=true;
handler(XMLHttpRequest.responseText,error);
},
type: "POST",
data: $("form:not(#UserLoginForm)").serialize(),
dataType: "json",
processData: false,
success: function(data, textStatus, XMLHttpRequest) {
$('.content').html(data.html);
var href = data.address;
var url = $.bbq.getState( "url" );
$.bbq.pushState({ url : href });
console.log("loaded new page");
bindFunc();
}
});
source
share