javascript,jquery,post,angularjsRelated issues-Collection of common programming errors


  • lhk
    javascript compiler coffeescript switch-statement
    I’m trying to use a simple switch statement but it doesn’t compile. Here’s the code:tag = 0 switch tagwhen 0 thenalert “0”when 1 then alert “1”The coffeescript compiler complains about an “unexpected then” in the line after the switch statement. I changed the code to this:switch tagwhen 0 then alert “0”when 1 then alert “1”and it works fine.But I need multiple statements on multiple lines in the then parts of the switch statement. Is that impossible ?

  • Roger F. Gay
    javascript html5 internet-explorer dom
    I’m having a problem getting simple HTML5 DOM processing to work on MSIE 9. It works without a DOCTYPE tag. But with the inclusion of DOCTYPE html (indicating html5), MSIE 9 doesn’t process it. Is there another way that I can do this so that it works as html5?The code attempts to create a nodeList by getting a DOM node and getting elements from that by tag name. The simple test is to display the nodeList.length. This is a small sample of what I see as a larger problem in the application I’m buil

  • Peter O.
    javascript html firefox button hyperlink
    I have two links inside a button but the links don’t seem to work on Firefox.<button class=”btn login”><a href=”/login”><b>Log In</b></a> | <a href=”/signup”><b>Sign Up</b></a> </button>I tried JavaScript onclick and redirecting – even that is not working.

  • dystroy
    javascript google-analytics universal-analytics
    On localhost, I disable my google analytics code by incorporating it into an if statement like so:var s = window.location + “”;if (s.indexOf(‘localhost’) < 0) {//GA universal analytics tracking snippet }However, throughout my site there are various event tags using ga(‘send’, ‘event’, etc…); – when my GA snippet is disabled on localhost these functions return errors (Uncaught ReferenceError: ga is not defined).Is there a way to disable these functions without putting them all into their own

  • Mico Francisco
    php javascript ajax
    I tried putting this code:<script>function myfunc(){var xmlhttp;if(window.XMLHttpRequest)xmlhttp = new XMLHttpRequest();elsexmlhttp = new ActiveXObject(“Microsoft.XMLHTTP”);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4 && xmlhttp.status==200)alert(xmlhttp.responseText);elsealert(“Something went wrong!”);}var tbl = document.GetElementByID(“tbl_users”);var str=””;var tid;var isActive;for(x=0; x=tbl.rows[x]; x++){tid=0;isActive=”true”;if(tbl.cells[1].checked)tid=1;els

  • brendosthoughts
    javascript html css addthis
    Hey so I have chosen to use the social sharing widgets that are provided by addthis.com basically becuase I thought they would make my life easier, and they provide alot of data analytics free of charge. I through them into my sight without problem added metatags for facebook and everything worked perfectly on the homepage. sharing works exactly how id like it to. However i then navigated a way from home page elsewhere in site and they don’t appear (I embedded them into a top panel wich occurs

  • Paul
    javascript jquery html html5-audio
    I would like to know how to mute all audio within a specific div class. This is mainly to mute ads playing unexpected videos or commercials on my site. I have the all of the ads under the div class “muted” so I would like to mute those divs but still allow for youtube videos (obviously outside the divs) to play the audio. Any help is appreciated.. Thanks

  • David
    javascript asp.net postback
    I’ve just added some JavaScript to the onclick of a Button in ASP.NET to disable the button (in order to prevent the user submitting the form twice).When I click this button, the page posts back fine but no control event handler runs – ASP.NET seems unable to determine which control posted the page back.I’m a bit stumped by this unexpected behaviour. Can anyone explain it and suggest an alternative way of doing this?

  • Jonathan Leffler
    javascript jquery
    Possible Duplicate:How can I obfuscate JavaScript? I want to “protect” my Javascript code. Are there any good, recommended ways which are very difficult to hack?I tested some encoder on the Web and sometimes my Javascript code doesn’t work after encoding. Is this normal (cot the encoder is very bad)?… or is my code too bad/buggy?

  • Tom
    javascript jquery dom
    I have a very weird problem. I am using jQuery and i am using the $(function () to load functions when the dom is loaded. But with a unknown reason the code in the $(function () will run a second time. A preview is at: http://development.devhouse.nl/news/3/het-nieuwste-nieuwsbericht you will get 2 alert prompts, but there is only 1 written in a $(function () . The exact code is:<script type=”text/javascript”>$(function () {alert(‘Test’);}); </script>And the whole source can be found

  • Damien
    jquery asp.net-mvc ajax error-handling
    Does anyone have a elegant way of dealing with errors in ASP.Net MVC? I constantly run into issues when dealing with requests to controller actions where the Action can be used for both normal requests and AJAX requests. The problem I have is finding an elegant way of dealing with these issues.For example, how could I handle validation errors? Ideally I would like to submit the form to a server via AJAX and then return any errors the action threw and display them on the page, but for the same to

  • Paul
    javascript jquery html html5-audio
    I would like to know how to mute all audio within a specific div class. This is mainly to mute ads playing unexpected videos or commercials on my site. I have the all of the ads under the div class “muted” so I would like to mute those divs but still allow for youtube videos (obviously outside the divs) to play the audio. Any help is appreciated.. Thanks

  • MFB
    jquery ajax syntax
    This code keeps throwing an “unexpected token’ error, but I can’t figure out what is wrong with it. Any clues would be great.function addComment() {$.ajax({url:’/add/comment/id’,type:’POST’,data.JSON.stringify({‘Text’:$(‘#comment_text’).val()}),contentType:’application/json; charset=utf8′,processData:false,success:function(data){$(‘#comments’).prepend(data.comment.Text);}}); }

  • Eric
    jquery
    $(‘#PbtnSubmit’).click(function() {if ($(“#PricingEditExceptions input:checkbox:checked”).length > 0) {var chec = $(‘#PricingEditExceptions input[type=checkbox]:checked’);var PMstrIDs = chec.map(function() {return $(this).val();}).get().join(“,”);alert(PMstrIDs);$(‘#1_exceptiontypes’).attr(‘value’, exceptiontypes)$(‘#1_PMstrIDs’).attr(‘value’, PMstrIDs);} else {alert(“please select atleast one exception”);return false;} });var checked = $(‘#PricingEditExceptions input[type=checkbox]:checked’)

  • Jonathan Leffler
    javascript jquery
    Possible Duplicate:How can I obfuscate JavaScript? I want to “protect” my Javascript code. Are there any good, recommended ways which are very difficult to hack?I tested some encoder on the Web and sometimes my Javascript code doesn’t work after encoding. Is this normal (cot the encoder is very bad)?… or is my code too bad/buggy?

  • Tom
    javascript jquery dom
    I have a very weird problem. I am using jQuery and i am using the $(function () to load functions when the dom is loaded. But with a unknown reason the code in the $(function () will run a second time. A preview is at: http://development.devhouse.nl/news/3/het-nieuwste-nieuwsbericht you will get 2 alert prompts, but there is only 1 written in a $(function () . The exact code is:<script type=”text/javascript”>$(function () {alert(‘Test’);}); </script>And the whole source can be found

  • user1576183
    javascript jquery settimeout
    In fact, when I usesetTimeout(a(),60); setTimeout(a(),120); setTimeout(a(),180); setTimeout(a(),240);It is supposed to be 60ms gap between calling’s of a functions.But it isnt, especially when it is fired during page loading or animating elements. In fact that gap gets even 2x longer when browser ‘has hard work to do’. In some cases it can be visible easly.The point of question is – is there any other way to synchronize events or functions in time in javascript?

  • Marve
    javascript jquery navigation links
    I am trying to write a skp nav link script but instead of grabbing the id i want to grab the class. How can I write the following script in jquery syntax to get the class name? $(document).ready(function() {$(“.ajax-video”).click(function(event) {event.preventDefault();document.getElementById(“currently-playing-title”).scrollIntoView();}); });Also for some reason the following does not work: $(‘.videoplayer’).scrollIntoView();

  • Benjamin Stoner
    jquery html
    Ok im a bit of a novice when it comes to javascript but i have been giving it a go with the help of the jquery library.I have a navbar with 3 links which upon clicking expand a relevant div on the page and also adds/removes the “current” class to which ever button you press. There is also a close button within the expanded div when this is pressed the div collapses again and the “current” is removed from the links but for some reason the link which was last pressed is not losing the class and st

  • Eli
    javascript jquery jquery-plugins source-code semicolon
    This question already has an answer here:What does the leading semicolon in JavaScript libraries do?4 answersWhats the purpose of starting semi colon at beginning of JavaScript? [duplicate]2 answersI’ve seen some strange ; at the beginning of a function in some jQuery plugins source code like this:;(function ($) {…..Can someone explain why they need to use ; in this case?

  • wx13
    javascript jquery ajax post
    I am trying to authenticate with a remote service through jQuery. First, I verify that I can do this outside of the browser:curl -X POST -H “Content-Type: application/json” -H “Accept: appliction/json” -d ‘{“username”:”…”,”password”:”…”}’ http://example.com/authThis successfully returns a token.Now I try it with jQuery:$.ajax({url: “http://example.com/auth”,type: “POST”,dataType: “json”,contentType: “json”,data: {username:”…”,password:”…”},error: function(data){alert(JSON.stringify(data

  • Federico Elles
    oracle http post utf-8 plsql
    I want to send an UTF8 json string via utl_http to a node.js Server via POST. Sending the string[“Sant Julià de Lòria”]does arrive as[“Sant Juli� de L�ria”]The PL/SQL code goes like:FUNCTION http_post_varchar(p_url VARCHAR2,p_request_body VARCHAR2 )RETURN VARCHAR2 ASreq UTL_HTTP.REQ;resp UTL_HTTP.RESP;value VARCHAR2(32767); — URL to post tov_url VARCHAR2(200) := p_url;– Post Parametersv_param VARCHAR2(32767) := p_request_body;v_param_length NUMBER := length(v_param); BEGINreq

  • Justin
    php post curl
    We are passing a ssh public key via an API call, using POST. The strange thing is, when we get the value in PHP, the plus (+) signs are completely stripped. Clearly, this does not work, as it changes the value of the public key.See the following raw curl request:curl “https://api.example.com/v1/keys” -X POST -d “key=ssh-dss AAAAB3NzaC1kc3MAAACBAOLsyYuyI0/3/UjajY8ljdgkAV2k9jZxjlVGWvHa9afMuO7DqsOcu0o4e5D9TPScsO5XrgTrmcXHkOtM54fOPdXSzonWOXUIn1XEumdHDlv9YRZTCW/A9qajhPR67y+92su9AqeGXI0/q3BXZsZcC1nr1N

  • Jonathan Julian
    ruby-on-rails ruby json post curl
    I set up a simple new rails application with model entry, with attributes title and content using scaffolding. now I am trying to use curl to POST the JSON data (rather than using the browser). the following seems to work (i.e. successfully posted with null data):curl –verbose –header “Accept: application/json” –header “Content-type: application/json” –request POST –data “” http://localhost:3000/entriesthe following does not work:curl –verbose –header “Accept: application/json” –header

  • rattmuff
    java json post
    I’m trying to send a JSON object to a server on a custom port. I never get any response back from the server however. I think the error might be in the string entity but I can’t figure out what it is.I’ve had a look at these other issues:HTTP POST using JSON in Javapost json to java serverHow to build a http post request with the correct entity with Java and not using any library?How to POST data to server in JSON formatNone of them have solved my problem. I’m trying the solution (16 votes) from

  • Benjamin
    php json post decode
    I receive JSON code in PHP but if I try to decode it nothing happens.CODE:$json = stripslashes($_POST[‘json’]); $output = json_decode($json);When I log $json and $output to the console:$json value is : {“post”:”{‘newfavorite’:'<div id=”1″ class=”favorite”><sub class=”minID”>Id 1</sub><a href=”http://www.youtube.com/watch?v=1PXQpWm_kq0″>http://www.youtu</a><span onclick=”movefavorite(1)”><img class=”move” title=”Move” src=”icon/move.png”></span><

  • mxmissile
    ajax post get firebug options
    I have an issue where I executing an AJAX request. Instead of seeing the normal POST or GET preceeding the action page url, I see OPTIONS. The data is successfully posted, but there is no response from the action page. What does OPTIONS indicate?

  • Daniel
    ajax file post input foreach
    input file not work :form.php<form action=’process.php’ method=”post” enctype=”multipart/form-data” > <input type=’text’ name=’name’ /> <input type=’file’ name=’photo’ /> <input type=’submit’ name=’submit’ /> </form>process.phpif($_POST){foreach($_POST as $key = > $value ){if($key!=’submit’)echo $key.’=’.$value.'<br/>’; }}output:name=name?! who can solve this problem for input files. please helpppppp….

  • JCS
    java xml exception post webserver
    I am trying to post XML data to a server which processes this XML and gives a response back, some times the XML data can be very large and the server takes a while to process it, in those cases i fail to get any response back instead i receive a IOException with the message “Unexpected end of file from server”. I am positive the XML being sent to the server is not full of errors, is there anything i can do on my end to make sure this doesn’t happen or is this a server side issue? Below is code

  • Fred -ii-
    javascript facebook post photo
    Error Uncaught SyntaxError: Unexpected number appears on the line:image[0][url]:photourl,Complete code is:function photoToPage(page) {FB.api(‘/’+page.id+’/clubinfophotos:shares’, ‘post’,{image[0][url]:photourl,image[0][user_generated]:true,access_token: page.access_token,message:msg},function(res) { console.log(‘Photo posted successfully’); }) }

  • tanepiper
    unit-testing angularjs jasmine angularjs-directive
    I’m writing directive tests for AngularJS with Jasmine, and using templateUrl with them: https://gist.github.com/tanepiper/62bd10125e8408def5ccHowever, when I run the test I get the error included in the gist:Error: Unexpected request: GET views/currency-select.htmlFrom what I’ve read in the docs I thought I was doing this correctly, but it doesn’t seem so – what am I missing here?Thanks

  • Sinetheta
    angularjs
    Data-binding to a directive’s attributes results in an error demo:<div goo-progressbar value=”{{progress}}”</div> Error: Syntax Error: Token ‘progress’ is unexpected, expecting [:] at column 3 of the expression [{{progress}}] starting at [progress}}]. at Error (<anonymous>)Is there a way to pass in live values so that I can have a dynamic directive?

  • MaxWillmo
    javascript performance angularjs
    I have a medium sized angular app which uses angular-1.2.10 and ui-router-0.2.8. When I transition to a particular state I am getting frame rate issues on the animation regardless of if I am using $animate on a ng-show or manually animating it.When I dig into the profiler I can see that the $apply after the XHR is taking up to 200ms. Which I am presuming to be the cause of the lag. When I remove the code in the state I am going to, this problem goes as expected.There is no large ng-repeat, and

  • tamakisquare
    angularjs angularjs-directive
    I have always thought ngShow and ngHide act as boolean counterpart to each other. That belief, however, is shaken by the unexpected behaviour of ngShow when an empty array is involved.Here is a demo plunker. Why isn’t ng-show=”!emptyArray” behaving like ng-hide=”emptyArray”?

  • mishik
    javascript angularjs
    This question already has an answer here:AngularJS toggle class using ng-class2 answersI tried this:<li ng-repeat=”todo in todos” class=”{{todo.isCompleted ? ‘test’}}”> <input type=”checkbox” class=”toggle”/> <label>{{todo.text}}</label><button class=”destroy”></button> </li>But then I got an error:Error: Lexer Error: Unexpected next character at columns 17-17 [?] in expression [todo.isCompleted ? ‘test’]

  • Dave Newton
    javascript angularjs escaping
    I have a directive which i’d like to pass a path<mydirective api=”/my/tomcat/server?asd=123&efg=456″>However I get “Lexer Error: Unexpected next character”. I assume some encoding needs to take place. Can someone advice?

  • Mat
    angularjs
    How to express a condition in ng-if directive ?Right now I tried this <div ng-if=”{ selectedTab == ‘decoupage’}”> … Syntax Error: Token ‘==’ is unexpected, expecting [:] at column 15 of the expression [{ selectedTab == ‘decoupage’}] starting at [== ‘decoupage’}].I’m using Angular 1.2.0.

  • FutuToad
    angularjs unit-testing jasmine
    I have a situation in my unit test where the ngProgress plugin is making http calls, which is messing up my unit tests as I am getting unexpected get errors:Uncaught Error: Unexpected request: GET http://upda…here is the stack grace> request(), app.js:35 deferred.promise.then.wrappedCallback(), > angular.js:10597 deferred.promise.then.wrappedCallback(), > angular.js:10597 anonymous(), angular.js:10683 $get.Scope.$eval(), > angular.js:11576 $get.Scope.$digest(), angular.js:11421 >

  • zishe
    node.js coffeescript angularjs mocha zombie.js
    I have an issue with testing my application with both jasmine-node and mocha (with zombie). The point is angular doesn’t work with this test environment – when browser.visit “http://localhost:3000/” it displays only layout, and don’t render any templates link. I guess javascript doesn’t run in browser (I mean zombie object) at all. My test Is there any way to make it works? Or problem is different?In jasmine spec that i copied from another project spec occures an error:/home/alder/Node/angular-e

  • alonisser
    angularjs karma karma-runner
    Karma angular unittest runner fails for no apparent reason, doesn’t run any test and just shows (in the cli):Chrome 30.0.1599 (Linux) ERROR Uncaught SyntaxError: Unexpected token< at /home/Documents/Projects/angular/app/index.html:2 Chrome30.0.1599 (Linux): Executed 0 of 0 ERROR (0.314 secs / 0 secs)but the index.html file is just standard .. at it runs perfectly with the app. and the “offending line” is just:<!DOCTYPE html>The browser shows only the default:Karma v0.10.2 – conn

Web site is in building