javascript,django,google-chrome,cross-domainRelated issues-Collection of common programming errors


  • ProfK
    asp.net javascript jquery
    I’m trying to call a Page Method using a jQuery ‘attached’ event function, in which I like to use the closure to keep the event target local, as below, but page method calls declare several ‘error’ functions, and I would like to use one function for all of them. If, in the below code, I was handling an error and not success, how could I use my single, anonymous handler for all 3 error functions?$(“:button”).click(function () {var button = this;PageMethods.DoIt(function (a, b, c) {alert(button);

  • BlairHippo
    javascript
    I’m trying to change the value of a text input field based on user actions. I’m doing it like this:document.getElementById(textFieldID).value = newValue;It isn’t quite working — the original text in the field remains on the screen, unchanged. However, when I submit the form, it behaves as though the value was indeed changed correctly. (And a debug alert confirms that yup, I’m hitting that bit of the code and passing in the right field ID and text value.) Anybody have any insights? Is there

  • Jürgen Thelen
    javascript jquery javascript-events
    The below code works well on localhost using XAMPP. But it doesn’t work on another server.<!DOCTYPE html> <html><head><script src=”jquery-latest.js”></script></head><body>word: <input type=”text” id=”sub” />user: <input type=”text” id=”user” /><button type=”button” id=”btn”>Click Me!</button><script>$(“#btn”).click(function () {var word=$(“#sub”).val();var usr=$(“#user”).val();alert(“hi”);});</script></body> <

  • Ketema
    javascript syntax coffeescript
    I have the following valid javascript:App.Person = DS.Model.extend({ firstName: DS.attr(‘string’), lastName: DS.attr(‘string’), birthday: DS.attr(‘date’),fullName: function() {return this.get(‘firstName’) + ‘ ‘ + this.get(‘lastName’);}.property(‘firstName’, ‘lastName’) });According to js2coffee.org This js is the equivalent of the following coffee script :App.Person = DS.Model.extend(firstName: DS.attr(“string”)lastName: DS.attr(“string”)birthday: DS.attr(“date”)fullName: ->@get(“firstName”)

  • mu is too short
    javascript coffeescript
    This is my coffee, I simply can’t see why this is wrong. I keep getting an unexpected , error. renderTable:()=>@table = d3.select(“#search-results-area”).append(“table”).attr(“id”,@tableId).attr(“class”,”visualization-panel”)@thead = @table.append(“thead”)@tbody = @table.append(“tbody”)@input = @table.append(“input”).attr(“id”,@inputId).on(“keydown”,(d)=>console.log(“keydown”)console.log toFilter = $(@input[0][0]).val() window.setTimeout(()=> toFilter = $(@input[0][0]).val() @tbody.sele

  • dopatraman
    javascript regex
    I’m using a the .replace() method in javascript to convert a serialized array of objects into a simpler serialzed string. Here is my code:b = //string b = b.replace(/},{/gi, “},cb,,{“); b = b.replace(/}],[{/gi, “},cb,,row,{“); //The error is being thrown for this lineWhen I run this code I am getting an “Unexpected Token /” error for the third line. Why is this? The line is more or less identical to the line above it. Please help me figure this out.Note: I cant submit a string without the regex

  • Pointy
    javascript
    var bookmark_iterator = page_element.firstChild; do {// start insertionif (bookmark_iterator === null) {page_element.appendChild(div_el);break;}// middle insertionif (div_el.id < bookmark_iterator.id) {page_element.insertBefore(div_el, bookmark_iterator);break;}// end insertionif (bookmark_iterator === page_element.lastChild) {// if null will insert at the end per referencebookmark_iterator = null;page_element.insertBefore(div_el, bookmark_iterator);break;}// increment loopbookmark_iterator =

  • jlleblanc
    javascript html ajax mootools
    I’m trying to build some JavaScript in MooTools that fetches table row markup from the server, then adds it to a table. I have an object named htmlAjax that’s set as a MooTools Ajax object. The object gets the HTML from the server correctly (tested this in the Firebug console), but when I attempt to add this markup to a new element, the <td> elements get stripped out. Here is my function that captures the data from the HTTP request and attempts to add a row:htmlAjax.addEvent(‘onComplete’,

  • cspray
    javascript div
    I’m pretty new to javascript and programming and have run into a brick wall with my project. I have a div which contains the javascript to embed a quicktime player, when the page is first loaded no .mov file is pointed at by the page so a placeholder div is ‘unhidden’ and the player div is set to style.display = ‘none’.So far so good, the user then enters the name of the new movie, the placeholder div is hidden and the player div is unhidden. My problem is that the javascript in the player div d

  • user3057928
    javascript
    var cashRegister = {total:0,add: function(itemCost){total += this.itemCost;},scan: function(item) {switch (item) { case “eggs”: this.add(0.98); break;case “magazine”:this.add(4.99);break;}return true;} };cashRegister.scan(“eggs”); cashRegister.scan(“magazines”);console.log(‘Your bill is ‘+cashRegister.total);the output show NAN, and total is undefined. I tried cashRegister.total and this.total in the add method, no luck. What’s wrong with the code above?

  • Jonathan
    sql django commit
    I’m writing a bulk insert script using Django’s ORM + custom raw SQL. The code has the following outline:import sys, os from django.core.management import setup_environ from my_project import settings from my_project.my_app.models import Model1, Model2 setup_environ(settings) from django.db import transaction from django.db import [email protected]_manually def process_file(relevant_file):data_file = open(relevant_file,’r’)cursor = connection.cursor()while 1:line = data_file.readline

  • jack
    python django utf-8
    I got the following error when tried to add an entry to a Django model via generic relations.django.utils.encoding.DjangoUnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xb8 in position 24: unexpected code byte. You passed in ‘ASL/60Styles_Timeless-3_\xb8 CaLe.asl’ (<type ‘str’>)The model is like this:class MD5(models.Model):value = models.CharField(max_length=32, db_index=True)filename = models.CharField(max_length=100)content_type = models.ForeignKey(ContentType)object_id = models.Pos

  • Ankit Jaiswal
    django google-app-engine
    How can we create read-only or the non-editable fields in the admin panel? Following is a code snippet from my model:class AnswerVote(db.Model):answer = db.ReferenceProperty(Reply,required = True,editable= False)vote = db.BooleanProperty(default = False,editable= False)voter = db.ReferenceProperty(User,editable= False)I have tried editable = False and readonly_fields but nothing seems to work.I am getting an error message: __init__() got an unexpected keyword argument ‘editable’.Do these things

  • Deniz Dogan
    python django utf-8 lxml decoding
    I have a strange problem with lxml when using the deployed version of my Django application. I use lxml to parse another HTML page which I fetch from my server. This works perfectly well on my development server on my own computer, but for some reason it gives me UnicodeDecodeError on the server.(‘utf8’, “\x85why hello there!”, 0, 1, ‘unexpected code byte’)I have made sure that Apache (with mod_python) runs with LANG=’en_US.UTF-8′.I’ve tried googling for this problem and tried different approa

  • luc
    django unit-testing sqlite
    One of my unit-test is running Ok when executed in stand-alone but is failing when executed with the other tests of the testcase.I am receiving an unexpected 404 status when sending a post request.It seems that the pb is caused by a 404 exception when getting an object from database. If I comment another post on the same view in the previous test, then the problem doesn’t occur anymore.The pb seems to be caused by sqlite (memory or file). No error when using mysq but the testing process in much

  • Martin Thurau
    python django postgresql
    I’m trying to make a (Django) query to my database using the following syntax:Derp.objects.all()I have a production database and a default (development) database. So obviously, by default, that query above will use the default database.I’m having trouble figuring out how to select my other database. A coworker suggested the following:Derp.objects.all(using=”development”)But that returns a TypeError:all() got an unexpected keyword argument ‘using’Can someone tell me what the proper syntax is? I c

  • cyroxx
    python django
    I have a model in which error is thrown when ever i use python manage.py syncdbAt this line createdAt = models.DateTimeField(auto_add_now=True) and the error isFile “/home/vaibhav/TRAC/coupon-rest-api/couponRestApi/couponRestApiApp/models.py”, line 18, in tagscreatedAt = models.DateTimeField(auto_add_now=True) File “/usr/local/lib/python2.7/dist-packages/django/db/models/fields/__init__.py”, line 660, in __init__Field.__init__(self, verbose_name, name, **kwargs) TypeError: __init__() got an unex

  • Wade Williams
    python sql django tdd models
    Racking my brain on this one. The model seems true, theoretically all of the commented permutations should work— but the only things that can successfully retrieve the user is .filter and .all; .get doesnt work; I can deal with using either .filter or .all —- but why isn’t get working? I’ll reiterate that a direct SQL query works 100% in this case. All imports are in place and things are functioning great at a low level — again, Filter works, All works, but get fails for some reason. class

  • Quinton Robbins
    python django session cookies session-cookies
    I am setting up a payment gateway and am using sessions to store data across page requests. The class below is used for organizing and storing information to the session.class Gateway:def __init__(self, session_key=None, session_name=”FOO”):# Store session ID and nameself.session_key = session_keyself.session_name = session_name# Get the sessionsession = SessionStore(session_key=self.session_key)try :data = session[self.session_name]except :data = {user_id:None, checked_in:False }self.__di

  • Spike
    django
    Can someone explain what this error means and how to solve?This is the error message:**NoReverseMatch at /contacts/group/new/ Reverse for ”group_list” with arguments ‘()’ and keyword arguments ‘{}’ not found.**the urls.pyurlpatterns = patterns(”,url(r’^$’, ‘contacts.views.home’, name=”group_list”),(r’^group/new/$’, ‘contacts.views.group’, {}, ‘group_new’),(r’^group/edit/(?P<id>\d+)/$’, ‘contacts.views.group’, {}, ‘group_edit’),)the template.py<li><a href=”{% url ‘group_list’ %}

  • user1313330
    javascript ajax google-chrome highcharts
    I am trying to load a fairly large highcharts chart by loading the javascript for the chart with ajax. As in the entire chart is loaded by ajax, not updated by ajax. This works on all charts on firefox(even if it is really slow) and all but the largest charts in chrome. Any chart that has more than roughly 65000 characters (probably unsigned 16 bit variable but not sure) throws an ‘Unexpected end of input error’ in chrome. I have had charts just above this limit, then by simply reducing the numb

  • Katana314
    javascript google-chrome getusermedia
    So the standard way that navigator.webkitGetUserMedia is used is like such:function success() {console.log(‘User accepted’); }function deny() {console.log(‘User rejected’); }navigator.webkitGetUserMedia({video: true, audio: true}, success, deny);The site I’m developing absolutely needs the use of the user’s webcam and microphone (actually, using Flash, but that seems to go through this API now), so I’m trying to do everything to ensure the user always knows what they need to click for the site t

  • Dyvor
    javascript regex json firefox google-chrome
    I have the following JSON string, encoded with PHP 5.2 json_encode():{“foo”:”\\.”}This JSON string is valid. You can check it out at http://www.jsonlint.com/But the native JSON.parse() method (Chrome, Firefox), throws the following error, while parsing:SyntaxError: Unexpected token ILLEGALDoes anybody of you know, why I cannot parse escaped regular expression meta chars?This example works:{“foo”:”\\bar”}But this one fails also:{“foo”:”\\?”}BTW: \. is just a simple test regular expression, which

  • ANTLRStarter
    javascript google-chrome exception-handling compiler-errors position
    How can I get the JavaScript source file/line number, maybe position of an error which is intercepted by an uncaughtException handler?. I’m using Chrome. error.stack as mentioned here Node.js doesnt display entire error message on uncaughtException, is it possible? doesn’t work (only text “SyntaxError: Unexpected token .”, but I get all the infos in the Chrome debugger.

  • Chris
    javascript python regex google-chrome firefox
    Here’s a little experiment, using the regular expression (.+)+, that I pulled out in my Chrome console:”abcd”.match(/(.+)+/) [“abcd”, “abcd”]which is utterly unexpected and weird. I tested in Firefox and the result was the same. However, in Python:>>> re.findall(r'(.+)+’, ‘abba’) [‘abba’]I can’t explain this. Anyone has an idea of might be happening in JavaScript’s engine?

  • haxxxton
    javascript jquery google-chrome safari hover
    ***SOLVED***Hey guysI am currently trying to make some jquery hover effects render correctly in all browsers. For the moment, firefox, IE, opera all do what they are supposed to. However, Safari and Chrome do not.the code looks like this:<div id=”button1″><div id=”work_title” class=”title_james”>WORDS </div> </div> <div id=”button2″><div id=”work_title” class=”title_mike”>MORE WORDS </div> </div>and the script effecting it looks like this<script

  • Joel Pearson
    debugging google-chrome angularjs webstorm
    I followed Vojta’s video about how to do debug angularjs in Webstorm.http://www.youtube.com/watch?v=MVw8N3hTfCI&feature=plcpHowever, every time I stop the testacular server in webstorm. I have to reinstall the webstorm debug extension for chrome. Am I doing something wrong? Do I need to install it into some Chrome profile or something?

  • user3002092
    javascript html5 internet-explorer google-chrome asp.net-mvc-4
    I have a really basic snippet of javascript code that works in Internet Explorer, but not Google Chrome. Here’s the line it breaks on:var formChildren = document.getElementById(‘myForm’).children;This is the first line in my script. The error I receive is: cannot read property ‘children’ of null.Does anyone know if I’m missing something? I can’t imagine why Chrome would error out on such a basic line.This is part of an MVC 4 project if that makes any difference.Thank you in advance!

  • Eric
    google-chrome svg
    I have an SVG document hereOn firefox, everything works as expected. However, google chrome appears to think this line:<image … xlink:href=”/textures/Cube top.png” />references http://minecraft-cube.comuv.com/index.svg, not http://minecraft-cube.comuv.com/textures/Cube top.png, resulting in unexpected recursion.Obviously, I’d much prefer it if it used the image I specify.What is going on here?EDIT: Filed bug #68732 in Chrome. May still be doing something wrong though.

  • knobcreekman
    jquery asp.net-mvc-3 internet-explorer google-chrome firefox
    I have some markup like this:<li id=”myId” data-foo=”Bar”>Text</li>In IE, I am succesfully getting the value of data-foo with $(‘#myId’).data(‘foo’), but it is not returning anything in Chrome or Firefox. For what it’s worth info: The page is generated by asp.net mvc from a template. The function that is trying to access data-foo is called from a popup launched from the page containing the <li> element above. I have also tried $(‘#myId’).attr(‘data-foo’) with no luck eitherTha

  • Trant
    javascript iframe cross-domain
    I am trying to use postMessage/receiveMessage to access the response of a cross-domain request via an iframe.The iframe calls a resource which usually does a particular operation, but when there is an error it instead responds with a script snippet that calls postMessage.This was working in development environment but in production it fails and I guess it has something to do with HTTPS but not sure how to resolve it.The response code looks like this:<script> $.postMessage(whateverData, ‘ht

  • PaparazzoKid
    jquery ajax json cross-domain jsonp
    I am building a simple app for a platform called Mixi, which is like Facebook in Japan. Now, in the Javascript API I am trying to fetch user’s profile information as per given API and after passing the correct auth token. The API link works perfect if I trigger it from my address bar in the browser. But, after hours of fiddling with it, and trying JSONP and all possible variants which I could find, Chrome’s console does show data but only when I click on this error:Uncaught SyntaxError: Unexpect

  • Dobes Vandermeer
    facebook json cross-domain
    I’m running into this error. The app seems to work OK but it causes Firebug to stop the scripts.JSON.parse: unexpected characterLine 9 (all.js)The line in question looks like this:FB.provide(‘JSON’,{stringify:function(a){if(window.Prototype&&Object.toJSON){return Object.toJSON(a);}else return JSON.stringify(a);},parse:function(a){return JSON.parse(a);},flatten:function(c){var a={};for(var b in c)if(c.hasOwnProperty(b)){var d=c[b];if(null===d||undefined===d){continue;}else if(typeof d==’

  • Raks
    html html5 svg cross-domain embed
    The issue is about Chrome throwing Cross Domain Error on using file urlI am embedding a svg document into a HTML using the object tag with the data attribute in the form of relative path, upon onload event I want to get the SVGDocument using getSVGDocument().I am accessing the html file using file url, when getSVGDocument is called, Chrome gives a Cross Domain Error. Chrome actually does embed the SVG but getSVGDocument does not return the DOM for the SVGThe Chrome Error is “Unsafe JavaScript a

  • hh54188
    jquery ajax cross-domain
    I use jquery ajax to do a cross-domain request job:$.ajax({type: ‘get’,url: ‘http://someurl’,dataType : “jsonp”,jsonp: ‘callback’,success: function (data) {} })but there is occur a error:Uncaught SyntaxError: Unexpected token :my request json data is just like:{“status”: “ok”, “info”: {“book_count”: 54, “title”: “recommended”}, “books”: [{“iap_price”: “”, “book_category”: “yippee_education”, “book_category_desc”: “\u4e50\u8c5a\u65e9\u6559”, }] }So what’s wrong with my code?How can I fixed this p

  • megaSteve4
    php include cross-domain common-files
    I have a series of web sites all hosted on the same server with different domains. I want to host some common PHP scrips and then be able to call these from the other domains.Im am a bit fresh with my php so pls excuse code attempts – I have tried iterations of the following which may try and help you understand what I am aiming for!from within php tags …include(‘http://www.mydomain/common_include.php?show_section=$section’);$show_section = $_GET[‘show_section’]; include(‘http://www.mydomain/

  • bahadir arslan
    javascript android xmlhttprequest cross-domain
    I have problems with Access-Control-Allow-Origin at Android 4.1In my application i have some local HTML files and Javascripts which i was using to fetch data from web services. Until trying Android 4.1 there was no problem but after trying at Android 4.1 i got this error.I read lots of documents but i couldn’t find a way to solve this problem.

  • Cory House
    jquery ajax json cross-domain
    Here is two pages, test.php and servertest.php.test.php<script src=”scripts/jq.js” type=”text/javascript”></script><script>$(function(){ $.ajax({url:”testserver.php”,success:function(){alert(“Success”);},error:function(){alert(“Error”);},dataType:”json”,type:”get”})})</script>testserver.php<?php $arr = array(“element1″,”element2”,array(“element31″,”element32”)); $arr[‘name’] = “response”; echo json_encode($arr); ?>Now my problem, When both of these files on same ser

  • zapico
    wcf silverlight cross-domain
    I’m having a really strange problem (at least it is strange because it has worked for me in the past) with a Silverlight Application consuming WCF services.When I debug both Silverlight Application and WCF in localhost it works perfect. When I publish both projects, they work perfect. The problem is when I try to debug the Silverlight Application against published WCF… it throws the typical crossdomain exception.I promise I’ve both clientaccesspolicy.xml and crossdomain.xml uploaded into the r

  • McBride
    javascript asp.net post video cross-domain
    I’m trying to send a video to a cross domain site using standard Ajax request: $.ajax({ url: ‘http://site2.com/RecordVideo.aspx?user=U&video=V, type: ‘POST’, dataType: “json”, contentType: ‘application/json; charset=utf-8’, data : ‘{“”}’, success: function(data) {console.log(“It Works!!”);}, error: function() {console.log(‘duuh!.’);} });And in the page load, I receive the post data and store it.But, the sending data is not Working…None of the videos are lower than 20mb, so it does not wo

Web site is in building