Download & Extend

Blank screen after block submission

Project:Advanced Poll
Version:6.x-1.x-dev
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

Well, not totally. I see this on the screen
{ "statusMsgs": "\x3cdiv class=\"messages status\"\x3eYour vote was registered.\x3c/div\x3e", "response": "\x3cdiv class=\"text\"\x3e\x3c!--paging_filter--\x3eWhen You Were Young (The Killers)\x3c/div\x3e\x3cdiv class=\"bar\"\x3e\x3cdiv style=\"width: 50%;\" class=\"foreground\"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\"percent\"\x3e50% \x3cspan class=\"votes\"\x3e(2 votes)\x3c/span\x3e\x3c/div\x3e\x3cdiv class=\"text\"\x3e\x3c!--paging_filter--\x3eMississippi Queen (Mountain)\x3c/div\x3e\x3cdiv class=\"bar\"\x3e\x3cdiv style=\"width: 25%;\" class=\"foreground\"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\"percent\"\x3e25% \x3cspan class=\"votes\"\x3e(1 vote)\x3c/span\x3e\x3c/div\x3e\x3cdiv class=\"text\"\x3e\x3c!--paging_filter--\x3e(Don\'t Fear) The Reaper (Blue Oyster Cult)\x3c/div\x3e\x3cdiv class=\"bar\"\x3e\x3cdiv style=\"width: 25%;\" class=\"foreground\"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\"percent\"\x3e25% \x3cspan class=\"votes\"\x3e(1 vote)\x3c/span\x3e\x3c/div\x3e\x3cdiv class=\"text\"\x3e\x3c!--paging_filter--\x3eMain Offender (The Hives)\x3c/div\x3e\x3cdiv class=\"bar\"\x3e\x3cdiv style=\"width: 25%;\" class=\"foreground\"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\"percent\"\x3e25% \x3cspan class=\"votes\"\x3e(1 vote)\x3c/span\x3e\x3c/div\x3e\x3cdiv class=\"text\"\x3e\x3c!--paging_filter--\x3eShe\'s a Badmammajamma (Carl Carlton)\x3c/div\x3e\x3cdiv class=\"bar\"\x3e\x3cdiv style=\"width: 25%;\" class=\"foreground\"\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv class=\"percent\"\x3e25% \x3cspan class=\"votes\"\x3e(1 vote)\x3c/span\x3e\x3c/div\x3e\x3cdiv class=\"total\"\x3eTotal votes: \x3cem\x3e4\x3c/em\x3e\x3c/div\x3e\x3cform action=\"/advpoll/cancel/67\" method=\"post\" id=\"advpoll-cancel-form\"\x3e\x3cdiv\x3e\x3cinput type=\"submit\" name=\"op\" id=\"edit-submit\" value=\"Cancel your vote\" class=\"form-submit\" /\x3e\x3cinput type=\"hidden\" name=\"form_token\" id=\"edit-advpoll-cancel-form-form-token\" value=\"3619cc7a21cb5099eabce5eb025ebd8a\" /\x3e\x3cinput type=\"hidden\" name=\"form_id\" id=\"edit-advpoll-cancel-form\" value=\"advpoll_cancel_form\" /\x3e\x3c/div\x3e\x3c/form\x3e" }

I'm theming the block like this.

<?php
function oxm_advpoll_block_mostrecent() {
 
$node = advpoll_mostrecent();
 
$output = "<div class='poll_wrapper'>";
 
$output .= "<div class='poll_text'>";
 
$output .= "<h1 class='yellow_txt'>$node->teaser</h1>";
 
$output .= "<p class='white_txt'>$node->title</p>";
 
$output .= "<div class='poll_hr'></div>";
 
$output .= drupal_render($node->content);
 
$output .= "</div>";
 
$output .= "</div>";
  return
$output;
}
?>

I think it's from doing using an image button in my form alter:

<?php
 
// oxm - poll button image
 
} elseif($form_id == 'advpoll_voting_binary_form') {
   
$img_src = base_path().path_to_theme()."/i/btn_vote.gif";
   
$img_ovr = base_path().path_to_theme()."/i/btn_vote_over.gif";
   
$form['vote']['#type'] = 'imagebutton_oxm';
   
$form['vote']['#image'] = $img_src;
   
$form['vote']['#attributes']['onmouseover'] = "this.src='$img_ovr';";
   
$form['vote']['#attributes']['onmouseout'] = "this.src='$img_src';";
   
$form['vote']['#attributes']['class'] = "poll_btn";
}
?>

The info is submitted. If i reload the page after submission, i get the node view showing the results.

It would be best if I could just skip the node view altogether and have it just reload the current page.

Comments

#1

The block as well as the nodes uses JavaScript to submit the the poll. If I knew a way to do it I would suggest you turn off javascript for the block to submit it as usual, but I don't :)

I would suggest you find out the exact code in your custom theme that breaks the JavaScript and then try to work around it. Start with the default theme function and go from there.

#2

Do I have to turn on something for the block to submit with ajax?

#3

hmm.. this is weird. I turned off all theming for the block and i get the same issues.

#4

I found that advpoll is trying to use ajax, but instead just printing out to the page with

function _advpoll_vote_response($node, $form_values) {
  $msg = t('Your vote was registered.');
  // Ajax response
  print_r($form_values);
  if ($form_values['ajax']) {
    list($node->voted, $node->cancel_vote) = _advpoll_user_voted($node);
    $ajax_output .= advpoll_view_results($node, NULL, NULL);
    // Remove linebreaks as they will break jQuery's insert-HTML methods
    $ajax_output = str_replace("\n", '', $ajax_output);
    drupal_set_header('Content-Type: text/plain; charset=utf-8');
    //### THIS IS PRINTING TO THE SCREEN
    print drupal_to_js(array('statusMsgs' => '<div class="messages status">'. $msg .'</div>', 'response' => $ajax_output));
    exit();
  }
  // Usual response
  else {
    drupal_set_message($msg);
  }
}

Whats wrong?

#5

Another clue, I took a default drupal install and installed the module and it works correctly. So it must be something incompatible with my theme or a module. Not sure where to start?

#6

Status:active» fixed

As I tried to say, start with the default setup and add you code incrementaly until something breaks. Then try to find the exact code that's causing the error. Basig bug hunting really, but unfortunately you are kind of your own on this as it's your own custom code.

#7

No, I heard what you were saying, just wanted to add those comments incase any of the symptoms were recognized. Thanks for the help.

#8

Yep, and it's nice to know that it's not the module that is broken :) Good luck!

#9

Ok.. i got it fixed. An older module I ported to drupal5 was writing javascript to the output buffer and that was causing all the problems.

Thanks for putting up with me ;)

#10

I finally tracked down specifically what is causing the problem. The site I'm working on uses hitbox. And when ever I include that script, I get the ajax response spit out to the screen. Have you seen anything like this with hitbox javascript before?

#11

Another development, If i go in and add alert() calls to the advpoll-vote.js, clear the browser cache and reload, the ajax submission works. ??? what is going on?

#12

Remove the alerts, clear the browser cache, and see if it works.

#13

This is so weird. It doens't work, then I go in add a newline in the advpoll-vote.js script, save it, clear-cache, reload and it works in one browser, but from another machine it spits out the ajax response after taking the same steps.

if you want to see it in action: (don't want to post the dev url here)
AOL IM : twerent

#14

Any other thoughts?

#15

grrr.. looks like im back to the hitbox javascript doing something to disrupt the ajax request.

#16

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

#17

just for the record, I have the same blank screen issue and I don't see why or how this is happening. I may update this thread if I find a solution.

#18

Version:5.x-1.0-beta5» 6.x-1.x-dev
Status:closed (fixed)» active

Guys I also got same problem when used advanced poll , problem was i was using D-6 foy My Website and when i submitted poll it shows the JSON output or blank screen , when i debugged the code i found the function _advpoll_vote_response() which creates the output when you press submit . here after line

print drupal_to_js(array('statusMsgs' => ''. $msg .'', 'response' => $ajax_output));
exit();

There is and exit(); . just comment out this exit and your page will not go blank , and shows correct output.
As i am a Novice drupal developer so i am not confident about it so might be this was not actual solution but this worked for me, try this may be this will work for you guys too.

Best Luck Guys
: The AJ :)

#19

Version:6.x-1.x-dev» 5.x-1.0-beta6

My issue seems to have started randomly after adding the jgrowl module.

#20

For my case, I got the same issue due to the fact that jquery.form.js is loaded AFTER advpoll-vote.js.
If you turn on Javascript error console, you can see "ajaxform not found".

Since the js is not functional, when you submit the vote, the next page will show the blank page with the jason result...

#21

Makes sense. I had to turn off the poll module until this is sorted. Perhaps the ordering of the js will correct this.

#22

Version:5.x-1.0-beta6» 6.x-1.x-dev

I have same behavior on 6.x

nobody click here