JQuery UI Tabs 1.10 Post Data

I just switched from JQ UI 1.8.23 to 1.10. As for this version, it is ajaxOptionsdeprecated and is now in use ui.ajaxSettings.

This is what my code looked like:

$( "#tabs" ).tabs({
        ajaxOptions: {
            type : 'POST',
            data : 'format=html',
            error: function( xhr, status, index, anchor ) {
                $( anchor.hash ).html(
                    "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                    "If this wouldn't be a demo. " );
            },
            success: function() { 
                *Something in here*
            }
        }
    });

everything worked perfectly. Now the new code:

$( "#tabs" ).tabs({
         beforeLoad: function( event, ui ) {
             ui.ajaxSettings.type = 'POST';
             ui.ajaxSettings.data = 'format=html';
             ui.jqXHR.error(function() {
                 ui.panel.html(
                 "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                 "If this wouldn't be a demo." );
                });  
             ui.jqXHR.success(function(){
*something in here*
                });
        }
    });

Therefore, I need to send this data format=htmlto my server, but with the new version my mail variables sent to the server are empty. Nothing is sent to the server. Also, if I want to get the POST variables in mine PHP , the array is empty. I am using ZENDbtw. I need to send it via POST - there is no way around this.

thanks for the help

+5
source share
3 answers

jQuery.ajax, 486 , URL. 532 beforeSend, beforeLoad jQuery.

, , , URL, :

$( "#tabs" ).tabs({
    beforeLoad: function( event, ui ) {
        ui.ajaxSettings.type = 'POST';
        ui.ajaxSettings.url += ( /\?/.test( ui.ajaxSettings.url ) ? "&" : "?" ) + 'format=html';
        ui.jqXHR.error(function() {
            ui.panel.html(
                "Couldn't load this tab. We'll try to fix this as soon as possible. " +
                "If this wouldn't be a demo." );
        });  
        ui.jqXHR.success(function(){
            *something in here*
        });
    }
});
+3

. :

ui.ajaxSettings.url += ( /\?/.test( ui.ajaxSettings.url ) ? "&" : "?" ) + 'format=html';

a GET a POST.

:

ui.ajaxSettings.format = 'html';

.

, :

 ui.ajaxSettings.data = { format:'html' };

.

+2

, , PetersenDidIt ! ajax , , - !

    $("#tabs").tabs({
        beforeLoad: function(event, ui) {
            var url = window.location.protocol + "//" + window.location.hostname + "/ajax";
            var data = {name: "job", value: "Rock Star"};

            ui.ajaxSettings.type = 'GET';
            ui.ajaxSettings.url = url  + "?" + $.param(data, false);

            //console.log(ui.ajaxSettings.url);
            ui.jqXHR.fail(function() {
                ui.panel.html('Couldn't load this tab!');
            });
        }
    });

, jqXHR , JQuery UI ( 1.11.4) .

https://github.com/scottgonzalez/jquery-ui/commit/e3f94a87dc312c2225e9ebe7231d868820bd6150

+1

All Articles