Help using jQuery BBQ plugin with forms

I was trying to figure out how to use the jQuery plugin for BBQ.

I was able to add it to my site by copying the code from the site, but I can see that if I have a form on one of my tabs, I cannot post any results successfully.

Has anyone used this plugin and got used to its functionality? I need help in determining where to enter php code to process the form, and the results return the page loaded to the tab.

+3
source share
1 answer

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();
    //console.dir(event);
    var url = $.bbq.getState( "url" );

    $.ajax({
        url: url,
        error: function(XMLHttpRequest, textStatus, errorThrown) {
            error=true;
            //alert("communication error");
            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.dir(data);
            console.log("loaded new page");
            //alert('Load was performed.');
            bindFunc();     
        }
    });
+3
source

Source: https://habr.com/ru/post/1757765/


All Articles