Posted by taite11 on November 26, 2008 at 12:57am
44 followers
| Project: | Popups API (Ajax Dialogs) |
| Version: | 6.x-1.3 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I'm trying to use Popup Reference to create an image node. Image nodes are made with the Image module.
When I click "Save" or "Preview" the form says "Bad Response form submission" and has a red "close" link and an "OK" button.
I am able to reference Image nodes that already exist.
Comments
#1
Tried it with CCK Imagefield. Same thing happened.
#2
It seems this problem is related to the use of a file-upload-field.
I experience this problem using the fileframework-module and trying to add a new file using the file nodetype.
I'll be looking into how to solve this, but if anyone have any thoughts it would be very much appreciated.
#3
You might test out the Popups API 6.x-2.x-dev version. I have heard that it gets file upload working.
#4
So, this is due to the Popups API, not Popups: Add and Reference. Is that right?
With Popups API 6.x-2.x, I'm not getting the error message and it seems to upload correctly... but it isn't working very well otherwise.
#5
The issue is that the js & css files for the javascript file upload need to get loaded somehow. In popups 1.x it is up to the user (you). In popups 2.x it is trying to do it for you.
Please open up other issues to expand on "it isn't working very well otherwise."
#6
I have installed the latest dev for popups API, but still cannot upload files in the related node. I still have the same error... I emptied browser cache, and erased my nodereference field...
I created another field and still get the same error. I tried to run update.php but there are no updates available, so I did not run it.
Should I run with the dev version of this module as well? Anything I should try to test this? For me I stil get the same error message..
Patchak
#7
Working very well for me using the latest dev release of Popups 6.x-2.x (DRUPAL-6--2) and Popups Reference 6.x-1.x (DRUPAL-6--1)
Evidence: http://img.skitch.com/20090106-bhknahfj184ydjt84sg99itdeg.png
#8
I'm still getting the "Bad Response form submission" message and no action on actually creating the node. Using the latest CVS code from DRUPAL-6--2 of Popups and DRUPAL-6--1 of Popups Reference.
I'm trying to do this with a Node Reference CCK field and creating an "Image" type node (using image.module) in the popup.
Other Javascript (e.g., the Drupal tabledrag widget) works fine within the popup for other forms (like the content type field admin form).
Any suggestions or other info I can provide to help diagnose?
#9
I have submitted the following issues related to using these two modules (including 6.x-2.x version of Popups API).
#359524: text "add (machine name for content-type)" not the best
#359522: Adding nodes with cck imagefields - error 2: node created but not referrenced
#359520: Adding nodes with cck imagefields - error 1: Can't add additional cck imagefield while another image is in queue
#10
Where is the Popups API 6.x-2.x your talking about?
#11
Popups API 6.x-2.x-dev is at http://drupal.org/node/337098
#12
#13
I know this is closed, but I can confirm upgrading to Popups API 6.x-2.x resolves this. I'm using the alpha release and the error is gone. =)
#14
Hi guys,
I have same problem with popup API. Don't work with Image Module. Anyone can help me?
Sorry, but I'm not write in English very well.
Thanks,
Ana
#15
I got this error a lot - every time the login form would successfully submit.
I resolved it by setting the theme configuration settings for popups api as indicated in the README.txt file. Basically, you have to examine your page.tpl.php file for the id of the div that surrounds
<?php print $content ?>(for ex,<div id="content-inner">...</div>, then enter that in your theme configuration as#content-inner. jQuery and popups will use that to know which content to replace. I have not gotten any more errors since, hopefully this works for you as well.update: I saw this error using 6.x-1.3 and the solution I posted cleared it up for me. I've now upgraded to 6.x-2.0-alpha5, and now see the Bad Response form submission error, even after applying the theme settings.
update2: Check your firebug for the last response, it will probably show the error. In my case, it was a Drupal 404 page.
It'd be useful to try and parse or log the actual error message somehow, instead of displaying a generic fail message.
#16
Here is a synopsis of this bug so far.
You can successfully browse for an image, (I'm using imagefield) and then hit the upload button. Upon submitting the node we're editing, everything works fine.
However, if you do not hit upload, you get a 'Bad response form submission' message from popups.
#17
#18
Marked #414336: Popups and filefield module as a duplicate, but is has some more information that might be helpful. It says the $_POST is missing.
#19
Marked #470454: User Profile (user picture) as another duplicate, that one reports problems uploading user pictures in the user profile, but it sounds like the same bug.
#20
Marked #327817: Imagefield Upload doesn't work in popups. as another duplicate. That's an old issue that suggests checking that all the right javascript files are loaded in the popup.
#21
Thanks for consolidating these Karen.
I think the $_POST is the key here. More specifically, probably $_FILES. I'm not completely clear, but I think because the $_FILES is being posted when you hit 'Upload' through AHAH, that the regular form $_POST works correctly.
Question now is, how does this differ from a regular $_POST? Is imagefield/filefield doing something during a regular $_POST of a node creation that popups is unable to detect? pinging quicksketch...
#22
So I've tried a few more things today. Finally tried modeling the $.ajaxForm call within popups.js to be more like the $.ajaxSubmit within ahah.js... still no luck I'm afraid though. Here's what I've got so far. I just can't figure out why the response is being aborted from jquery.forms.js... as in the post doesn't even happen, it just aborts and the complete action is triggered with status = 'error'.
popups.js around line 938
// If the popups contains a form, capture submits.
var $form = $('form', popup.$popupBody());
if ($form.length) {
var options = {
beforeSubmit: function() {
Popups.beforeSubmit();
},
success: function(response, status) {
Popups.formSuccess(popup, response);
},
complete: function(response, status) {
if (status == 'error' || status == 'parsererror') {
return Popups.message(status, response);
}
},
type: 'POST',
dataType: 'json'
};
$form.bind('submit', function() {
$form.ajaxSubmit(options);
});
#23
just noticed this was assigned to someone not working on it.
#25
I found the root of the problem while investigating this problem this week. Here's a summary:
Currently Popups provides both a
beforeSendand abeforeSubmithandler. Both of these are interfering with the submission of files or are making assumptions that will not work with file submissions.The first problem is that in
Popups.beforeSubmit, we remove the current popup (before the form is submitted) withPopups.removePopup(). This effectively removes the form from the DOM. Then when ajaxForm() goes to complete the request, the form will be removed (including the file upload field) which results in the file never being uploaded, since file fields are not included in theformData.The second problem is that if the popup is not removed from the page, then
Popups.beforeSendisn't called at all. The option to use beforeSend is exclusive to $.ajax requests. But when uploading a file, $.ajax is not used, instead an iFrame is created and a post request is sent to the iFrame.Even if you fix the first two problems, there is yet another problem that is worse than those others. Right now Popups sets request headers with
xhr.setRequestHeader("X-Drupal-Render-Mode", 'json/popups');. However, when using iFrame based uploads it is impossible to set custom HTTP headers. This is because JavaScript does not have the capacity to upload files at all, since XmlHttpRequests are, nearly be definition, text-based. Since we can't use an XmlHttpRequest, we loose the ability to set custom headers, and we can only do what HTML allows us. Unfortunately HTML forms provide no mechanism for setting HTTP headers, leaving us with a mechanism that will not work for file uploads.So in short, we cannot use HTTP headers to request the rendering mode of the returned content. At least we can't do this if we want to have file uploads on submission of popups. I'd suggest that we abandon that approach and return to adding a hidden field within the submitted form, or using extraData to add extra content to the POST request. Newer versions of jquery.form.js actually create hidden elements for us before the request, which could be convenient for this purpose.
#26
Wow, awesome sleuthing quicksketch! Thank you.
Currently I've implemented a hack that adds a new click handler to the submit button, which will detect the upload button and trigger it's mousedown event, then, set an interval looking for the returned element from ahah and then submit the form. I know it's pretty nuts, but it actually works.
I'll look into your suggestions and report back. Thanks again.
#27
sirkitree would you mind posting the code for that on this forum? Thanks!
#28
I also would love to have a development snapshot with this hack in it.
#29
Since this is a hack and not a solid solution, I'm not very willing to give it out. The code I have is specific to my installation and would most likely not work in most general instances but does with mine due to specific elements ID's and classes that correspond with other functionality. I'd much rather encourage others to try to come up with an extensible solution.
#30
subscribe.
#31
desperately subscribing
#32
Have someone tried this #460744: Cannot Create New File Nodes Using Popups API comment #3?
#33
My solution for this problem is to add an additional javascript from the filefield module.
popups_add_popups(array('add_node'=>array('additionalJavascript'=>array(drupal_get_path('module', 'filefield').'/filefield.js'))));And it works for me!
#34
I was wrong, it only works as admin and only on firefox (not safari). very strage
#35
subscribe
#36
subscribe
#37
I can't upload new pictures to nodes with image_attach.module, no errors, node is submitted, but without image.
Any progress on solving this issue? Image.attach doesn't seems to be using any js to uploading, as upload is starting on hitting node "submit" button unlike with file module where is "attach" button.
#38
Thanks to the detailed explanation of the problem by @quicksketch in comment 25 above, I've managed to fix the Popups API and to get image uploads to work. Yay!
My patch does the following:
beforeSendajax option, and thus also gets rid of the custom request header setting (as quicksketch said, this doesn't even get called when file uploads are present, and even if it did, setting the custom header would prevent file uploads from working too)$_SERVER['HTTP_X_DRUPAL_RENDER_MODE'](the HTTP header value), Popups now checks$_REQUEST['popups_header']. This is a GET parameter when the popup form is loaded. When the form is submitted, Popups now expects modules that depend on it to injects a hidden form field called 'popups_header' into the form. This then gets submitted as POST data. Hence the need to use PHP's$_REQUESTvariable (which contains $_GET, $_POST and $_COOKIE values combined).textareaif$_SERVER['HTTP_X_REQUESTED_WITH']is not 'XmlHttpRequest'.removePopup()isn't called until the end of the process (as quicksketch said, it needs to be present when the form is submitted - I can confirm this).I've also submitted a patch for Add and Reference, which adds the necessary hidden 'popups_header' hidden field to the node form:
#617640: FileField and ImageField popups uploads broken
Hope this helps all you people who have been struggling with this problem. I've only patched Add and Reference myself - if this patch gets committed, other module built on Popups will no doubt need to be patched too.
#39
Hello,
@Jaza: thanks for the patch.
The uploading of files threw popups works now, but I got an other issue after applying this patch, described in #617870: Clicking the preview-button twice leads to a page with a textarea containigt popup-code.
The second thing is, that hitting the Upload-button leads to submission of the form and the progress bar is never shown.
Regards,
dendie
#40
The problem could be, that when I hit the preview button (or the save-button with a validation error), a second popup is comming up and overlays the fist one.
#41
Jaza why this patch is made for 6x1.3 instead 6.x-2.0-alpha5?
#42
Updated patch, for this thread and for:
#617640: FileField and ImageField popups uploads broken
Which fixes most of the preview issues, and also the issue of a second popup coming up and overlaying the first one.
The 'preview' button and the image 'upload' button: both of these are causing the form to submit instead of to preview (for me), so I decided to simply remove these buttons in a form_alter hook in a separate custom module for my site. You may wish to do the same. I didn't include that code in this patch, and I don't think it belongs in popups module - but it's my approach to fixing the solution for now.
@Shaman: this patch is for 6.x1.3, because that's the version of popups that I'm using. I'm using popups on a client site, and I prefer to use the latest stable branch rather than using alpha code. Feel free to port the patch to the 6.x-2.0 branch of popups.
#43
Hello,
now i get a "Bad Response from submission"-popup after hitting save-button. This message-popup is overlaying the page-submission-popup. When I close the message-popup, the page-submission-popup will be closed and a second message-popup apears (or the first one remains open).
Regards,
dendie
#44
Hey Jaza,
Your patch worked for me, but there are a few things that needs some fix
1. I had to apply the patch manually because it did'nt work in my version. (6.x-1.3)
2. Does not work for me in combination with your last patch for the issue: http://drupal.org/node/617640
The second one has to do with the other module, so i'll post more details on that thread.
Regards
#45
Hey PHPepe,
I had also to modify the patch-file before I could apply it.
Can you reproduce my issue from #43? If not, what I am doing wrong?
Thanks,
dendie
#46
1.3 doesn't have popups chaining as well as js is loaded manually so it's not best idea to use it.
#47
@dendie: I was getting the same error, whenever I submitted a popup form that either didn't have any file upload field, or that had a file upload field that I left empty.
According to the jQuery form docs, the
$_SERVER['HTTP_X_REQUESTED_WITH']variable is supposed to be set when doing a form submission that involves no file uploads. However, this variable didn't appear to be available to my script when I debugged it. So instead, I'm using jquery.form's 'iframe' option, to force the form to always submit in an iframe, and I'm always outputting the response wrapped in a textarea.Updated patch attached.
#48
#49
@Jaza does this patch reatly work for you?
Now I get a "Unable to open: http://mysite.com/node/add/page" message after applying this patch.
Without this patch the popup opens without problems.
Thanks,
dendie
#50
@Jaza
I have the same problem as dendie, and it looks like all the popups can't be open...
dropchew
#51
subscribing. Getting "Bad Response form submission" error.
#52
removing all form tags and posting without forms works fine, i use onclick/onchange js function to assign inputs to vars then call a ajax function to do the posting without page refresh. "Bad Response form submission" gone.
#53
just want to indicate that I'm experiencing the same problem - however I'm using Popups with my own custom module that does file uploads, so these patches don't work for me
#54
I hope this information could be useful to someone: I had the "Bad Response form submission" and I solved in this way:
- installation of Popups API 6.x-2.0-alpha5
- installation of Popups: Add and Reference 6.x-2.0-alpha1
- switching off the option "Optimize JavaScript files" in "Site configuration"->"Performance"
#55
I am still getting the same "Bad Response form submission" error using the solution posted by kongoji in #54.
#56
Hello,
Thanks for patch. Can you provide this patch for Drupal5 popups module.
Thanks in Advance
#57
Popups Reference 6.x-1.3 upon the Popups 6.x-2.x-dev should work well if we upload the file before submission.
#58
The patch that Jaza provided doesn't work for me either I get the same error as others
#59
Subscribing
#60
subscribing
#61
Subscribing
#62
Hi,
With the following patch works for me with FileField.
#63
Sorry the correct is this. Working with version 6.x-2.x-dev
#64
This #63 patch works when upload failed.
But if upload success, I still get "Bad Response form submission"
#65
Popups.beforeSubmit = function(formData, $form, options) {
// Popups.removePopup(); // Remove just the dialog, but not the overlay. I removed it, then upload successfully in firefox.
Popups.addLoading();
};
No matter whether I remove or keep it, upload successfully in Chrome but get "Bad Response from submission".
#66
subscribing
#67
We have this problem in 6.x-2.0-alpha6.
#68
Subscribing
#69
Subscribing
#70
subscribing
#71
subscribing
#72
Subscribe
#73
subscribe
#74
subscribe
#75
I am not sure if this patch will help to anyone but for my situation this worked.
I have popups link (class="popups") that calls custom Webform form. After form submission I would always get "Bad Response form submission" so I noticed that for me "destination" param in Popups ajax URL is suffice, this param is always added in
Popups.js. Previously I noticed similar bugs with destination param involved with some other modal screens and forms/form submissions.This patch checks if our link has additional class "form" and if so skips setting "destination" param.
In other words, with this patch applied, when I change class attribute in my link from:
<a class="popups" >to:
<a class="popups form" ...Webform submission is now working (no matter of its own redirection setting, all options work here).
As I said, I am not sure if this has to do with this issue in particular but maybe it can help on the road to fix.
#76
Hi,
I am still experiencing the "Bad Response form submission" with the module and the Popups API. I use
popups_reference 6.x-2.0-alpha1
popups 6.x-2.0-beta0
I tried the several patches but no luck on this.
Did anyone manage to get this working with the versions above?
#77
Unfortunately all patch from Jaza (one, two) and nk_'s patch dont help me.
Still get "Bad Response form submission" or "Unable to open: http://site.com/%webform_url%".
Popups 1.3, Drupal 6.20.
#78
#79
Running either a D6 or D7 site, I think your better option is to update your code to use CTools modals (part of the ctools.module), which previously also had the problem with uploads but has subsequently been fixed (at least over a year now). CTools is also likely to be installed by most sites running D7 (since its required by Views) and many D6 sites. It's generally a more robust solution that has been tested by many more users than Popups module.