Error on API calls that return Boolean results (Chrome)

Create issue
Issue #117 resolved
Timothy Keesey repo owner created an issue

SyntaxError: Unexpected token <.

Comments (7)

  1. Timothy Keesey reporter

    There seem to be two possible solutions:

    1. Upgrade Django, or
    2. Ensure that the AJAX call sets its CONTENT_TYPE metadata.

    (Or both.)

  2. Timothy Keesey reporter

    Server reports errors like these:

    Traceback (most recent call last):
    
      File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
        response = callback(request, *callback_args, **callback_kwargs)
    
      File "/usr/lib/python2.6/site-packages/django/db/transaction.py", line 217, in inner
        res = func(*args, **kwargs)
    
      File "/var/www/phylopic/data/www/phylopic.org/phylopic/api/views.py", line 313, in synonymy_toggle
        enabled = _read_enabled(request)
    
      File "/var/www/phylopic/data/www/phylopic.org/phylopic/api/views.py", line 71, in _read_enabled
        enabled = request.POST.get("enabled", None)
    
      File "/usr/lib/python2.6/site-packages/django/core/handlers/modpython.py", line 101, in _get_post
        self._load_post_and_files()
    
      File "/usr/lib/python2.6/site-packages/django/http/__init__.py", line 282, in _load_post_and_files
        if self.META.get('CONTENT_TYPE', '').startswith('multipart'):
    
    AttributeError: 'NoneType' object has no attribute 'startswith'
    
    
    <ModPythonRequest
    path:/api/a/synonymy/7b3826e3-842f-40e6-862b-f9665de784b6/bc11f7fc-33dc-4300-9e69-04450c330818/toggle,
    GET:<QueryDict: {}>,
    POST:<could not parse>,
    COOKIES:{'__utma': '125979724.319054623.1364835561.1364835561.1364839626.2',
     '__utmb': '125979724.49.10.1364839626',
     '__utmc': '125979724',
     '__utmz': '125979724.1364835561.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
     'sessionid': 'cf55118b354fac71eb7c18cf1e1e8936'},
    META:{'AUTH_TYPE': None,
     'CONTENT_LENGTH': '0',
     'CONTENT_TYPE': None,
     'GATEWAY_INTERFACE': 'CGI/1.1',
     'HTTP_ACCEPT': 'application/json, text/javascript, */*; q=0.01',
     'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3',
     'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch',
     'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8',
     'HTTP_CONNECTION': 'Keep-Alive',
     'HTTP_CONTENT_LENGTH': '0',
     'HTTP_COOKIE': 'sessionid=cf55118b354fac71eb7c18cf1e1e8936; __utma=125979724.319054623.1364835561.1364835561.1364839626.2; __utmb=125979724.49.10.1364839626; __utmc=125979724; __utmz=125979724.1364835561.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)',
    
  3. Timothy Keesey reporter

    Ensured that AJAX calls send the content type, even if there is no data. (That was the common thread, not the Boolean result.)

  4. Log in to comment