Miscellaneous => Roundcube Discussion => Topic started by: Lambda89 on April 12, 2010, 09:44:14 AM
Title: Roundcube "Button" for post data?
Post by: Lambda89 on April 12, 2010, 09:44:14 AM
Just a quick question. Is the roundcube: button require to be able to send post-data from a form correctly? I've been working with a normal for a plugin so far, and no matter what I've tried, there always seem to be no data in the $_POST-array.
If the answer is "No", I'd be glad to post my code if someone would be nice enough to help me debug it.
Best regards
Title: Roundcube "Button" for post data?
Post by: rosali on April 13, 2010, 12:37:21 AM
Did you really have the slash behind the opening tag or is this just a typo?
Title: Roundcube "Button" for post data?
Post by: Lambda89 on April 13, 2010, 02:35:54 AM
It's a typo. My bad.
The biggest issue for me with is that it can't be loaded dynamically. I want to print a form via an AJAX-request, and I would preferrably avoid to load a new template into my content-div. So I would *really* like to use an "ordinary" submit for this particular task.
Title: Roundcube "Button" for post data?
Post by: Lambda89 on April 13, 2010, 03:43:02 AM
I'll go ahead and post the code immediately ... not to go ahead of anything, of course.
Title: Roundcube "Button" for post data?
Post by: Lambda89 on April 13, 2010, 07:24:42 AM
Sadly, this (print_r($_POST), to be specific) only generates a server-error. I then tried to send just my $_POST back to the JavaScript, to try to print it that way, but this prints nothing. Not even "Array". So, still, somehow my $_POST variable is emptied somewhere through the script, or it's never sent from the form at all.
I am very appreciative for your help, by the way. I'm pretty much new to writing roundcube plugins, and the API for it can be a bit freightening sometimes (even if it's totally kickass).
Best regards
Title: Roundcube "Button" for post data?
Post by: Lambda89 on April 13, 2010, 09:28:21 AM
This is the JavaScript for posting the form, by the way. Could it be something in it that interferes with the $_POST-variable? Hehe, my head is going numb here. Been trying a tonne of different solutions, but nothing seems to work. :D
The JS: //Edit: The separation in the create is because of the formatting of the forum, it's not like that in the code.
Title: Roundcube "Button" for post data?
Post by: rosali on April 13, 2010, 06:33:01 PM
Well, $_POST is not empty! So handle the post data according to your needs. How to advice how to process valid data in your plugin ?!?
Title: Roundcube "Button" for post data?
Post by: Lambda89 on April 13, 2010, 06:39:43 PM
Thank you for going out of your way for my sake, but I figured out what I was doing wrong. The solution, or rather, my misconception was that the post-data automagically just followed my AJAX-request along. It does not. And the solution is to use var id = $('#id').val(); to get the values, and then pass them with their proper names to the request. For instance: '&_id='+id
Thank you again for taking your time to help me think things through.