stormdrain
stormdrain

Reputation: 7895

MochaUI Post data and MochaUI.updateContent

I'm playing around with mochaUI and am having a hard time getting POST data to work correctly. I have a form and a submit button. I am using MochaUI.updateContent to work within panels. In the main panel, I have the form and the following js:

<script type="text/javascript" charset="utf-8">
$('stp1btn').addEvent('click', function(e){
    MochaUI.updateContent({
        element: $('mainPanel'),
        method: 'post',
        data: "w=1",
        url: '/postFile.php',
        title: 'Test Post Stuff durrrrrr',
        padding: { top: 8, right: 8, bottom: 8, left: 8 }
    });
});
</script>

Which posts to a page which then is supposed to update the same panel. However, I can't get it to post correctly. Even in the above example where the sample data is simply "w=1", what is actually getting posted is "w=1" in addition to what looks like one of the mootools js files included within mochaUI:

This is the Form Data from Firebug:

0:w
1:=
2:1
$family[name]:string
test:function (a,b){return((typeof a=="string")?new RegExp(a,b):a).test(this);
}
contains:function (a,b){return(b)?(b this b).indexOf(b a b)>-1:this.indexOf(a)>-1;}
clean:function (){return this.replace(/\s /g," ").trim();
}
camelCase:function (){return this.replace(/-\D/g,function(a){return a.charAt(1).toUpperCase();});}
hyphenate:function (){return this.replace(/[A-Z]/g,function(a){return("-" a.charAt(0).toLowerCase());
});}[SNIP]

I am using a framework (codeigniter) which disallows query strings thereby preventing the post data from even seeing the destination php file.

The html on the page is all correct.

I've tried surrounding the data with both quotations and apostrophes.

I searched the nether-regions of the internet looking for answers. Found tits instead--so it wasn't a total wash.

If anyone could lend some insight into how/what would be injecting the js into the post data, I would be very grateful.

Upvotes: 0

Views: 850

Answers (2)

Dimitar Christoff
Dimitar Christoff

Reputation: 26165

just try this:

$('stp1btn').addEvent('click', function(e){
    MochaUI.updateContent({
        element: $('mainPanel'),
        method: 'post',
        data: { w: 1 },
        url: '/postFile.php',
        title: 'Test Post Stuff durrrrrr',
        padding: { top: 8, right: 8, bottom: 8, left: 8 }
    });
});

the mootools request does work with an object literal or otherwise for data - even can serialize a form element, so data: document.id("formel") is usually fine.

if the subclassing by mochaui is ok, then it should work.

Upvotes: 1

stormdrain
stormdrain

Reputation: 7895

<script type="text/javascript" charset="utf-8">
$('stp1btn').addEvent('click', function(e){
    var myRequest = new Request({
        url: '/le_formDerp.php',
        onSuccess: function(responseText){
            MochaUI.updateContent({
                element: $('mainPanel'),
                content: responseText,
                title: 'Test Post Stuff durrrrrr',
                padding: { top: 8, right: 8, bottom: 8, left: 8 }
            });
        },
    }).send($('stp1_form').toQueryString());
    myRequest.send();
});
</script>

hurrrrrr durrrrrr

Upvotes: 0

Related Questions