I have a table view with an flag link for each node. When I try clicking on one of the links, I get a javascript pop-up with an error message that says "An HTTP error 200 occurred..." followed by a long URL that ends in a &token= value.

Comments

jacobthetopdawg’s picture

I'm experiencing the same error using IE 8 when trying to flag content. Any ideas anyone?

mooffie’s picture

Status: Active » Postponed (maintainer needs more info)

When "An HTTP error 200 occurred..." shows up it usually because of some PHP error on your site. (One other possible reason: doing a page redirection upon flagging.)

To see the actual PHP error, open the link in a new window (or tab).

In other words:

Don't click the flag link with your left mouse button. Instead, click it with your right mouse button. Then, using the context menu, open the link in a new tab/window. The page you'll see will probably reveal something about why the error occurred. Please report back the result.

matt v.’s picture

It looks like it might be a Views issue:

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND flag_content_users.uid = 1) LEFT JOIN flag_content flag_content_node ON nod' at line 5 query: SELECT node.nid AS nid, node.title AS node_title FROM node node INNER JOIN users users ON node.uid = users.uid INNER JOIN flag_content flag_content_users ON users.uid = flag_content_users.content_id AND (flag_content_users.fid = AND flag_content_users.uid = 1) LEFT JOIN flag_content flag_content_node ON node.nid = flag_content_node.content_id AND (flag_content_node.fid = AND flag_content_node.uid = 1) in /path/sites/all/modules/views/includes/view.inc on line 735.

mooffie’s picture

AND (flag_content_users.fid = AND
...
AND (flag_content_node.fid = AND

Note that the 'fid' on the right side of the "=" is missing. This could happen if the flag doesn't exist.[1]

Examine the view. (Go to its editing screen.) Inspect all the flags names you see there (e.g. "bookmarks", "friends"; in the relationships), and make sure you haven't deleted any of them. It's certainly possible to have a view that reference flags that no longer exist ...this would generate the faulty SQL you saw.

-----
[1] But, then, taking $flag->fid would trigger a PHP warning ("Trying to get property of non-object")... it's interesting that you didn't report this. Maybe because the "official" Drupal doesn't alert of these warnings. I suggest you have a look in your watchdog log.

matt v.’s picture

StatusFileSize
new9.26 KB

I only have one flag field under the relationships section. I tried removing it, but that breaks the view. When I added it back in, I still received the error message in comment #3.

I tried deleting the bookmark flag that I think comes bundled with the flag module, just in case, and I still got the error. I also tried removing the exposed filter I had set up for the flag, and I still got the error.

On the off chance that it might help, I've exported the view and I'm attaching it here.

jacobthetopdawg’s picture

I opened a new tab as suggested, but it appears the flag went through ok with no mysql errors. However, when I try to just click on the flag link in the same window I get the HTTP error 200 message. You mentioned the problem could be a redirection issue. My link is looking like this:

http://192.168.1.100/drupal4/flag/flag/plus_favorite/270?destination=nod...

Could there be a problem in my links?

In FF, the flags work :( .

febbraro’s picture

For what it is worth, I have seen this issue (the error in views join) when I have a relationship to a flag that does not exist, or exists with a different name. The views relationship looks up flags by name. One way to figure out what is happening is to export the view and look at which flag name it is trying to join and verify that flag exists and is enabled.

Good luck.

mooffie’s picture

using IE 8 [...]
In FF, the flags work

Perhaps yours is a jQuery issue. Could you upgrade your jQuery and report back? (Use the '-dev' version of jquery_update, because its jquery is newer.)

mooffie’s picture

@Matt,

  • Perhaps turning on PHP's reporting of warnings could help locate the problem. If you're using the development version of Drupal then it's already turned on. Else, you'll have to turn it on: I couldn't find "official" instructions for doing this; I suggest you search this site for "E_ALL".
  • While its probably true that there's some error in the view, or a bug in our Views integration, I wonder why your left-clicking the link somehow causes Views to run. A question: does clicking a link (and it doesn't matter whether it's left-cliking or otherwise) cause the node to get flagged/unflagged?
cangeceiro’s picture

I am also getting similiar behavior from my site when I try to add a "Flagged Link" field in a table view. I'm using firefox, and and it throws an error when i click on add. the error is "An error occurred at http://192.168.1.34/admin/build/views/ajax/add-item/requests_marketing/d...."

If i copy that link into my browser and try to access it, i get a return with no errors. Also, if i refresh the page, it ads the field to my lists of fields. but the field isnt actually displaying anything in the table.

I would lean against this being an issue with a missing flag, as I only have 1.

cangeceiro’s picture

I found my problem...if its related. This appears to be a bug in views. I was able to fix mine by upgrading to 6.x-2-dev

mooffie’s picture

Cangeceiro, thank you for the report.

Once somebody corroborates this we should put this info on Flag's homepage.

matt v.’s picture

I just tried upgrading to Views 6.x-2-dev and it didn't fix the problem for me. I'm going to try recreating the view from scratch when I get a little more time. I'll report back.

mooffie’s picture

Status: Postponed (maintainer needs more info) » Active
pdcarto’s picture

Not sure if this is related, but when try to put a flag link into a node view where I'm using node id as an argument, the SQL includes a field 'users.nid', which throws a SQL error because users has no nid field.

cangeceiro’s picture

strangely this problem came back for me. but in a slightly different form. after upgrading to the dev version of views it worked for a day, and just this morning i started getting "Fatal error: Call to a member function get_views_info()" I have opened an issue on the views project at http://drupal.org/node/450690

jacobthetopdawg’s picture

In response to #8:

Jquery update with -dev version introduced other issues for me. ie broke ajax comments and broke fivestar module. I did notice that flags were going through, but without ajax animations. I'll keep investigating.

mooffie’s picture

Priority: Normal » Critical

Marking this 'critical'.

  1. Comment #15 suggests we have a bug in our Views support (flag_handler_field_op::query() is good suspect).

    As for the "HTTP error 200" alert box: It's a mystery because I don't see why any Views code gets called when one just clicks an ajaxy flag link.

  2. It might be that there's an unrelated issue lumped in this report: some IE8 Javascript compatibility issue (see comment #17, which is a reply to comment #8).
mooffie’s picture

As for the "HTTP error 200" alert box: It's a mystery because I don't see why any Views code gets called when one just clicks an ajaxy flag link.

Hey... perhaps Views erroneously attaches a Javascript click-handler to Flag's links when the view's AJAX support is turned on? I see that Views does .find('ul.pager > li > a, th.views-field a, .views-summary a') so Views is not supposed to pick up our links, but who knows. I can't check things further as I'm not running Drupal.

Could anybody turn off the view's AJAX support and see if it solves the "HTTP error 200" alert box problem?

matt v.’s picture

mooffie,

If you mean the "Use AJAX" option under the "Basic settings" section of the view, that was already turned off for the view I've been having trouble with. Just to be thorough, I tried turning off Javascript using the Web Developer Toolbar for Firefox and I still got the error message.

mitchell’s picture

merlinofchaos said in #450690: Fatal error: Call to a member function get_views_info() mentioned in #16:

Views does not contain the method 'get_views_info()' anywhere, nor try to call it. A grep for the string 'get_views_info' in Views turns up no results. You should look at see what file that call is on and file an issue against the module that provides that file.

Agreed, this is critical:

$ grep -lir "get_views_info" *
flag.incincludes/flag_handler_field_ops.inc
includes/flag_handler_argument_content_id.inc
includes/flag.views.inc
$ 
ebeyrent’s picture

Component: Code » Views integration

I also have this issue as described in #16. Any luck on solving it?

ebeyrent’s picture

Regarding #16, I found that when I had my flag configured to use multiple content types, I got the fatal error. When I removed the second content type, everything worked as expected.

boreg’s picture

I found solution :)
Its simple. U have to enable that flag u use in views. I mentioned it here: http://drupal.org/node/450690#comment-1796822

quicksketch’s picture

Status: Active » Postponed (maintainer needs more info)

I've never been able to reproduce this bug, but the solution posted by boreg in #24 sounds likely to be a fix. Sounds like a problem with flag_friend specifically creating a default view and a default flag that is disabled. Since a new version of Flag Friend has since been released, that might explain why the bug reports slowed or stopped. Unless there is some confirmation that boreg's solution does not fix the problem, I think we can close this issue.

quicksketch’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Closing after lack of response.

matt v.’s picture

Status: Closed (fixed) » Active

I've updated to the latest version of Views (6.x-1.8) and I'm still getting essentially the same error as in #3. In comment #24 above, is that referring to the "What nodes this flag may be used on" setting for the flag? If so, I have that set.

Can anyone help me pinpoint where the right-hand side of the "flag_content_users.fid =" argument gets set?

quicksketch’s picture

Matt V: Could you provide steps to reproduce this issue, or post an export that is very, very simplistic? The export you posted above seems complicated to reproduce, needing VotingAPI and custom node types and flags. It'd help to be able to easily reproduce this problem, as it is I'm not sure how to fix something I can't see.

matt v.’s picture

StatusFileSize
new2.87 KB

quicksketch,

Thanks for the quick response. Here is a simplified example that still exhibits the issue.

Bilmar’s picture

I have come across this issue, and hoping that someone found a fix.

Flag 6.x-2.0-beta1
Views 6.x-2.8 / 6.x-2.x-dev / Views 6.x-3.x-dev (2009-Dec-29)

Flagging a node once on the view seems to be ok.
The error appears when you try to unflag or flag another node listed in the view (the second call of the flag action).

An HTTP error 200 occurred.
http://www.example.com/flag/flag/wishlist/9?destination=search&token=b58...

Bilmar’s picture

additional information

Fatal error: Call to undefined function activity_record() in /home/example/public_html/includes/actions.inc on line 100

Browsers tested: Firefox and IE results in same error
Views AJAX: Yes and NO results in same error
Flag Link type: JavaScript toggle and Normal link results in same error

Error occurs when the flag/unflag action is clicked two times for the same node.

Example steps 1: flag Node 1, flag Node 2, flag Node 3, flag Node 4 [ALL OK, no errors]
Example steps 2: flag Node 1, unflag Node 1 [ERROR, however after page refresh Node 1 is unflagged]
Example steps 3: flag Node 1, flag Node 2, unflag Node 1 [ERROR, however after refresh Node 1 is unflagged]

However, after the error I refresh the views page and the Node that resulted in error from flag/unflag has been flagged/unflagged even though the error made it seems like nothing happened.

Please let me know if more information is required. Thanks in advance!

Bilmar’s picture

Turning ON the Activity module fixed the error. This is odd as I don't wish to use the Activity Module.
This would make it seems like the Flag Module is dependent on the Activity Module?

robby.smith’s picture

subscribing - is this still an issue in the latest dev?

matt v.’s picture

I did some cleanup of extraneous views on my site and oddly enough that seemed to resolve this issue for the remaining views. I even tried re-importing the simplified view I had exported for comment #29 above and that too worked fine after the cleanup.

Cousken’s picture

I had the same problem, and many more very similar, but they only affected admin account. I've tried a lot of troubleshooting and in the end i found out they were caused by Theme Developer module, they all disappeared when i disabled the module.

Check if the problems persist if you use a normal Authenticated User account, if they don't it is likely that Theme Developer is causing it, just like in my case.

quicksketch’s picture

Category: bug » support
Priority: Critical » Normal
Status: Active » Fixed

Sounds like (once again) this is an issue caused by other modules breaking AJAX requests rather than a problem with the module doing the AJAX. I don't believe this is a problem with Flag, and unless someone can create this problem from scratch on a fresh Drupal install, I don't think there's anything that can be done on our side.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

In case people keep having this problem,

watch out for the search404.module - I got "access denieds" on /flag/flag pages causing "HTTP ERROR 200" on js flags. Disabling the 404 module restored flags.

scrimothy’s picture

I'm running:
Drupal 6.19
Flag 6.x-1.3

I did not use Views for this particular node/page. I just added the flag_create_link() function to my node.tpl directly. I get the 200 error window, but when I click OK, and then refresh the page, the "Bookmark this" turns to "Unbookmark this" as it should and the user/%/bookmarks page shows the new node in the bookmark list (and vice versa for unbookmarking).

When trying other suggestions (i.e. right-click/open in new tab) all works well and I just redirect perfectly back to the original page with the bookmark link toggled the way it should. Also, same thing happens if I turn off JS (in Google Chrome and FF)...redirects fine through the bookmarking and back to the original page. Also, if I copy and paste the URL that is shown in the error window (http://example.com/flag/flag/bookmarks/18?destination=node%2F18&token=...), then again, it handles everything fine and toggles (changing "/flag/flag/" to "/flag/unflag/" as a toggle). It must be all about the JS that is an issue.

I can't seem to find an actual answer to this (or a patch/work-around). Has anyone figured this out or added a new fix for this issue? Thanks sooooo much!
Jimmy

dbers’s picture

Component: Views integration » User interface

I'm getting the same error. It looks like its an issue with changes made for jQuery 1.4 (http://api.jquery.com/jQuery.ajax/)

The json object being returned by the function isn't perfectly formated, there for 1.4 jquery throws an error.

I quick fix was to do adjust the flagClick() function in theme/flag.js

make this line:

dataType: 'json',
success: function (data) {

something like this:

dataType: 'text',
success: function (tmpData) {
data = jQuery.parseJSON(tmpData);

I don't believe this is an error with Fag module though, since it uses drupal_to_js() to return the json .
Later version of php (5.2+) can just use json_encode but earlier version needs a drupal_to_js thats stand

micnap’s picture

Version: 6.x-1.1 » 6.x-1.3

Ditto #39. HTTP Error 200 in IE7, FF 3.6, and Chrome 9.0. I tried doing what dbers suggested and it takes away the error alert but the little blue arrow just spins and never resolves although the flag does still get added/removed.

This is with a default install of flag using the bookmarks flag.

Running PHP 5.2.14.

Thanks,
Mickey

micnap’s picture

Update: The error is being caused by a widget on the page using http://code.jquery.com/jquery-latest.js. Reverting this back to jquery 1.3.x gets rid of the flag js error but then kills my widget. Don't know enough javascript to resolve it so I guess I'll be using the normal link instead of the javascript toggle.

Mickey

dbers’s picture

Whats your widget do?

I had upgraded to jquery 1.4 for jQuery Tools plugin.

But the 1.4 jquery was causing issues with the admin theme as well so i found an older version of jQuery Tools that could do what i wanted.

Perhaps look into doing the same thing (down grading your jquery)

darnzen’s picture

#39 above is what I'm seeing.

Here are the things I've tried (unsuccessfully) to try and resolve it:
Upgraded Drupal 6.20
Upgraded to Flag 6.x-2.0-beta5
Upgrading jQuery with jQuery-update module
Downgrading jQuery back to 1.2.6
Disabling many other modules, including views, quick tabs, global redirect, pathalias_xt, etc. etc.

Verified problem exists with user flags, node flags with multiple content types, node flags with single content type, default bookmarks flag, and global flags.

I did NOT disable CCK, content_profile, taxonomy, image_cache, and other basic functionality modules that I needed to even test the problem. All of these modules are up to date and 'green' on the update admin report.

Verified problem exists on IE8 and Chrome 11.0.696.60 beta, and Chrome "stable" release (can't remember the version number since I switched back to beta). I seem to remember it working on Firefox at one point, but for some reason I can't get FF to load any JS atm.

Oddly, I can't find the http:200 error logged anywhere. It's not in my apache log, mysql log, drupal watchdog. Even having the java console open doesn't show any errors.

Also, everything works fine without the JS toggle enabled. All the other JS on the site works fine.

HTTP: 200 is supposed to be successful "OK" code isn't it? At least according to http://en.wikipedia.org/wiki/List_of_HTTP_status_codes and http://www.w3.org/Protocols/HTTP/HTRESP.html

Maybe the problem is in the JS error handling?

ReKoNe’s picture

I have the same issue.

Following #2, i can see this error :
"Fatal error: Call to undefined function flag_reset_flag() in /www/sites/all/modules/flag_abuse/flag_abuse.module on line 70"

I am using "Flag 6.x-1.3" and "Flag Abuse 6.x-2.0-rc1"

titouille’s picture

Hello,

Updated from drupal 6.20 to drupal 6.22, same problem with http 200 error.

I have a modified version of jquery-update to get 1.4.2 in front site.

In include/common.inc, the drupal_to_js function is changed in 6.22. In 6.20, it use the json_encode method and it works fine :

function drupal_to_js($var) {
  // json_encode() does not escape <, > and &, so we do it with str_replace()
  return str_replace(array("<", ">", "&"), array('\u003c', '\u003e', '\u0026'), json_encode($var));
}

But in 6.22, there is a recursive method like this :

function drupal_to_js($var) {
  switch (gettype($var)) {
    case 'boolean':
      return $var ? 'true' : 'false'; // Lowercase necessary!
    case 'integer':
    case 'double':
      return $var;
    case 'resource':
    case 'string':
      return '"'. str_replace(array("\r", "\n", "<", ">", "&"),
                              array('\r', '\n', '\x3c', '\x3e', '\x26'),
                              addslashes($var)) .'"';
    case 'array':
      // Arrays in JSON can't be associative. If the array is empty or if it
      // has sequential whole number keys starting with 0, it's not associative
      // so we can go ahead and convert it as an array.
      if (empty ($var) || array_keys($var) === range(0, sizeof($var) - 1)) {
        $output = array();
        foreach ($var as $v) {
          $output[] = drupal_to_js($v);
        }
        return '[ '. implode(', ', $output) .' ]';
      }
      // Otherwise, fall through to convert the array as an object.
    case 'object':
      $output = array();
      foreach ($var as $k => $v) {
        $output[] = drupal_to_js(strval($k)) .': '. drupal_to_js($v);
      }
      return '{ '. implode(', ', $output) .' }';
    default:
      return 'null';
  }
}

And the return of this method is strange, embed with "[pre]...[/pre]" and with a space before the result, ie :

<pre> {status:1}</pre>

With #40 and using eval( '(' + tmpdata + ')' ) instead of jQuery.parseJSON(tmpData) it works fine with jquery 1.4.2.

Hope this can help.

llorberb’s picture

I have the same issue, but only when I am using tokens in the link text. Any suggestions.

wm753v’s picture

Same issue, but I solved it. In my case, I had added a javascript reference in my .info file:

scripts[] = scripts/jquery1.2.6.tools.min.js

When I removed this jquery reference it worked. The problem is, I need that jquery, so I'm looking for a solution for that now.

By the way, you can try using the different options on the Flag configuration page:
Link type:
JavaScript toggle
Normal link
Confirmation form

and try "Normal Link". If "Normal link" works, it would seem to suggest there is some javascript issue.

omar alahmed’s picture

I have the same issue, but I solved it by removing an additional jquery I added it for a plugin.

navi85sin’s picture

In my case, i just installed the jquery update module and it works.