ajax,node.js,session,express,ember.jsRelated issues-Collection of common programming errors


  • mmelear
    javascript jquery ajax
    I am trying to send an AJAX request to my spring backend. I am hitting the controller, and am successfully responding. I am new to javascript and AJAX, so I have hit a ceiling that I cannot get through. I am trying to call “done” on a successful callback, and am getting a very non-descript error. This is my console after I push “button”clicked testAjax. js:3 Uncaught SyntaxError: Unexpected token : product:1I haven’t created a product file, but when I go into it I get the object I am trying to

  • Munzilla
    javascript ajax html5 websocket accessibility
    One of the major requirements for accessibility standards such as WCAG is that the web site or application displays without the use of javascript or provides some sort of non JS alternative. I did some initial research and couldn’t find much information on this in regard to websockets. Should I assume websockets are treated similar to AJAX?

  • Miika L.
    jquery html ajax load
    I am using following code to load a html page inside a div,$(“#htmlViewer”).load(“conversion_test/to_convert_3264/”+getPageName(pageCount)+”.htm”, function(response, status, xhr) {if (status == “error”) {/* var msg = “Sorry but there was an error: “;$(“#error”).html(msg + xhr.status + ” ” + xhr.statusText); */jAlert(‘Unexpected Error : Please try again later’, ‘Alert’);pageCount–;}});In the above code I am getting only the HTML text but I am not getting CSS and the images in that page. To get t

  • John Conde
    javascript php jquery ajax
    I’m simply trying to read in a field from a text box, pass the value via ajax to PHP and then store the data in a mysql table. The table is already set up and ready to go, all I need is to insert values. Here is my js file var address = $(“input#email”).val(); //If submission is valid if(submitForm == “true”){$.ajax({ url: “bin/process.php”, type: “POST”, data: {email: address}, success: function(response) { $(‘#message’).html(response); }}); return false; }And then my PHP looks like this

  • Helena Standaert
    javascript ajax angularjs
    I’m building an angular app where I have a ‘public transportation’ section and I want to get directions from the google api. I seem to get a valid url – when I enter the url in my browser, it returns the json. But I get an error when user $.ajax.Urlhttp://maps.googleapis.com/maps/api/directions/json? origin=Assenede,%20Belgi%C3%AB&destination=Industrieweg%20232,Gent- Mariakerke,belgium&sensor=false&departure_time=1343641500&mode=transitFunction in angular controller$scope.getDire

  • user1871612
    javascript jquery ajax
    To ask about getscripthtml Code as follows:<!DOCTYPE html PUBLIC “- / / W3C / / DTD XHTML 1.0 Transitional / / EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html><head> <title>jQuery GetScript</title> <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js”></script> <script type = “text / javascript “> $(document). ready(function () {$getScript (‘script.js’, function (jd) {$.each (test, function (index, valu

  • Rohan Kumar
    php jquery ajax json
    Hi friends can anyone me for this plz. im new to this chapter..i am trying to get JSON format value from PHP but while im running i got this output “SyntaxError: JSON.parse: unexpected characte”.. i think i had done mistake in php conversion …plz help me friends my .html file<html> <head><script src=”http://code.jquery.com/jquery-1.8.3.min.js”></script><title>Display Page</title> </head> <body><button type=’button’ id=’getdata’>GetData.<

  • 404 Not Found
    php jquery ajax
    i have two division in my file say form.php….Division A All data from table abc (here i am getting data from db) Division BSome fieldsAdd Data (Button) will store data in table abc through ajax using following code (It’s storing data)Now my problem is when i add data in Division B i want to update Division A with newly added data through ajax…for that i am trying this code but i am getting console error say Uncaught SyntaxError: Unexpected identifier $(“#addField”).click(fun

  • Bill the Lizard
    php javascript jquery ajax
    I have a div, and I’m reloading it with Ajax every 1 second. And it has auto value as overflow. To keep my div always bottom, I’m using a javascript code in Ajax request.xmlHttp.onreadystatechange=function(){document.getElementById(‘chatting’).scrollTop = 9999999;if(xmlHttp.readyState==4){document.getElementById(‘chatting’).innerHTML=xmlHttp.responseText;setTimeout(‘Ajax()’,1000);} } var withdate=document.getElementById(‘firstdate’).value; nocache = Math.random(); xmlHttp.open(“GET”,”db.getMessa

  • Pat Friedl
    php ajax json wordpress json-encode
    I’ma making an ajax call in a meta box and returning some very simple data. However, it keeps throwing an error:parsererror SyntaxError: JSON.parse: unexpected non-whitespace character after JSON dataHere’s the ajax call:uid = new Date().getTime(); appReq = jQuery.ajax({type : ‘post’,dataType : ‘json’,url : ‘admin-ajax.php’,data : { action : ‘get_app_sidebars’, post_id : currentApp, uid : uid } }); appReq.done(function(data){if(data.widgetNum > 0 && data.widgetName != ” && da

  • Alex
    javascript node.js serverside-javascript control-flow call-graph
    Are there any Call-Graph and/or Control-Flow-Graph generators for JavaScript?Call Graph – http://en.wikipedia.org/wiki/Call_graphControl Flow Graph – http://en.wikipedia.org/wiki/Control_flow_graphEDIT: I am looking specifically for a static tool that let me access the graph using some API/code

  • Benjamin Netter
    node.js error-handling express
    I’ve been struggling for the past hours trying to find a decent tutorial on how to handle errors for a NodeJS + ExpressJS 3 api.I’ve read a lot of questions/answers on SO and read the official ExpressJS guide and still cannot figure out the proper way to do such an important thing. Most of the answers I found were relevant in Express 1 or Express 2, but are not anymore and the ExpressJS Guide just describes something out of context, which makes it really hard to understand.So here’s my use case

  • slezadav
    javascript node.js mongodb parameters
    Is there a way to execute a function from String passed as a request parameter and return result in node.js ? Imagine a request which contains String:”db.users.find()”as a parameterIf I knew I wanted to execute this statement I would do this:db.collection(‘users’, function(err, collection) {collection.find().toArray(function(err, items) {res.send(items);}); });What I want is something like a parser which would execute given statement and returned results.I tried like this:exports.execStatement =

  • rainabba
    windows node.js gruntjs node-inspector
    Running Windows 8.1 and my environment is working great except I cannot start node in –debug so that node-inspector has something to connect to.I have a Gruntfile setup with grunt-concurrent that lets me open, grunt-devtools, node-inspector then watch just fine but I can’t figure out a workable syntax for getting that running with node in debug. Following is what I’d expect to work but also the error I get when I try. Notice that there is a message indicating that the debug server is listening,

  • aks
    javascript arrays node.js mongoose
    I am making an application with Node.js, Express, MongoDB, Mongoose, and Passport.js. In my application users can write and store poems. I want to update the user when they delete a poem by removing the ID of the deleted poem from the “poems” field of the user document which is an Array of poem IDs. I’ve tried every permutation of the document.update call I can imagine, with and without a callback and none of them successfully remove the ID from the array.Here is my code now:exports.Delete = fun

  • Lekhnath
    node.js mongodb express mongoose jade
    In my node app I have designation model with following Schema.var DesignationSchema = new Schema({_id : ObjectId,designation : String });And this is embedded in users Schema.var UserSchema = new Schema({fname:String,lname :String,email :String,password :String,designations : [DesignationSchema] });User can select one / many designations from select list. Below is my jade implementation for creating select list;select(name=”designations”) – for(var i = 0; i < designations.length; i++) {option(

  • 580THz
    javascript node.js express
    What is the best way to separate all module dependencies into a new file called dependencies.js, and requiring that file in for example server.js. How do i return all these requires?var express = require(‘express’), stylus = require(‘stylus’), fs = require(‘fs’), https = require(‘https’), app = express();

  • cpeele00
    javascript node.js mongodb mongojs
    I have a document “owner” that can have “n” number of camps and camps have “instructors” and instructors have “classes”. Earlier I tried accomplishing this with nested arrays (see link to my post below), however I learned that the positional operator “$” does not nest that deep. MongoDB: Adding an array into an existing arrayHowever, I learned that the workaround would be to use object collections instead of arrays. I’m assuming that I have to use “update” with “$set” to add additional “camps”,

  • xbonez
    node.js
    running this code giving me this error, trying to fig out since an hour but failedvar http = require(‘http’); var url = require(‘url’); var fs = require(‘fs’); var port = 3010;http.createServer(function(req, res){var query = url.parse(req.url,true).query;console.log(query);var file = query.f + query.t;//var file = “eurusd_m1.json”; console.log(file);var eurusd;fs.readFile(‘data/’ + file + ‘_m1.json’, function(err,data){if (err){console.log(err);} eurusd = JSON.parse(data);console.log(

  • Patrick Roberts
    git node.js heroku
    Here’s the log:$ git push heroku master Counting objects: 79, done. Delta compression using up to 8 threads. Compressing objects: 100% (76/76), done. Writing objects: 100% (79/79), 228.60 KiB | 374.00 KiB/s, done. Total 79 (delta 20), reused 0 (delta 0)—–> Node.js app detected —–> Resolving engine versionsUsing Node.js version: 0.10.21Using npm version: 1.2.30 —–> Fetching Node.js binariesgzip: stdin: unexpected end of file tar: Child returned status 1 tar: Exiting with failure

  • Napster
    php jquery session
    I’m doing a online exam tool. I want to minimize the number of database requests. So I am requesting all the questions in the test at one go. After this I have to remember all the questions user has attempted and their answers. My plan is to save the answers in a php session variable like this$(‘input[type=radio]’).click(function() {var id = ($(this).parent().attr(‘id’));id = id.slice(4);$(‘#nav’+id).css(‘color’,’red’);<?php $_SESSION[‘ques[‘id’]’]= ?> $(this).val() <?php ;?> });In

  • Charles
    php zend-framework session destructor zend-session
    I’m noticing some slightly unexpected behaviour using __destruct to write data using Zend_Session_Namespace in PHP 5.3:public function __destruct(){$this->getSession()->data = $this->data; } // …. private function getSession() {if (! self::$zendSession) {// this next line is fine because the object is a singletonself::$zendSession = new Zend_Session_Namespace(self::SESSION_NAMESPACE);}return(self::$zendSession); }The destructor is getting called, but the data isn’t getting written. H

  • BalusC
    java session servlets captcha
    I am creating a CAPTCHA input using SimpleCaptcha, and did validation of the Captcha input. I am created a captcha input with the following codes.HTML Code:<form action=”submit_proceed.do” method=”post”> <img src=”captchaImg” /><input type=”text” name=”captcha” value=””><br /> <input type=”submit” value=”Submit” name=”submit” /> </form>JavaServlet Code :import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.

  • Gustavo Porto
    php image session while-loop protect
    I’m having a problem here and I think people here can help me.I have a file that generates an image, ler.php, and the file that loads the images through a while, the carregar.phpI need to let the blocked direct access to the images generated by ler.php, tried to make a system like this session:carregar.php:<? $_session[‘a’] = 1; while($a != 50) { echo “<img src=’ler.php?imagem=$a’>”; $a++; } $_session[‘a’] = 0; ?>ler.php:<? if($_session[‘a’] == 1) { //load image } ?>The result

  • Joel Coehoorn
    c# session httpcontext static-classes
    I separated all direct session interaction into a separate class and made it static, because I didn’t want to create a new object several times. However, i wish to make sure that there are not concurrency issues or other wonky suprises.Here is the code:public static class HttpHelper {public static string Get(string key){object value = HttpContext.Current.Request.QueryString[key];return (value == null) ? null : value.ToString();}public static string Post(string key){object value = HttpContext.Cur

  • Darren Sweeney
    php mysql session hacking
    I have the following code in a file which, when variable $action equals a certain value, a message is added to the database and then an email is sent to the user advising them of the message. Simple.Over the last couple of days there have been spam messages added to the database, and emails sent to users informing them of new messages. Not many and not all at once, just random times and content, but clearly spam.I set the script so that if the $from variable does not equal 0 then don’t proceed,

  • Samuel Kim
    asp.net session
    This is in regards to a situation where Session is used to store some temporary data – one example being information entered during a multi-step registration process.If a website has a number of such sections – which wants to utilize the session as temporary data store for pages within the section, what is a good way of cleaning up the session when the data is no longer required, considering that the user may simply navigate away from the section so the pages themselves cannot be used for cleani

  • joorva
    session object components tapestry
    During my battle with tapestry 5 I created some setup which does not work, and I don’t know why. I found few work-arounds, but still I would like to know why initial idea failed.I have parent abstract page class with application-wide auth procedure:public abstract class AuthPage {@SessionStateprotected UserAuth user;public Object onActivate(){if(user==null)return LoginForm.class;else if(user.getLoggedIn().equals(Boolean.FALSE))return LoginForm.class;elsereturn null;} }Then I have index page clas

  • Yasser
    session backbone.js asp.net-mvc-4
    I have an ASP.NET MVC4 sub web application added in to an existing ASP.NET WebForm web site. the whole website is using forms authentication.In my MVC4 client side, I use Backbone.js for building the application, and the client application is most likely a SPA. Everything works fine, but after session timeout my application does not redirect to log-in page.I tried the error callback on Collection.fetch method, it was triggered (which is good) when trying to fetch after session time out.However,

  • james2code
    asp.net session asmx
    How does IIS handles multiple simultaneous requests to a web service using the same session id when that web service relies on sessions? If the first web service call has not finished processing, does IIS queue the second web service call temporarily until the first web service call has finished (since they both rely on the same session data). Or does IIS allow both requests to go forward and any changes made to the session store by the first request immediately affect the second web service c

  • Benjamin Netter
    node.js error-handling express
    I’ve been struggling for the past hours trying to find a decent tutorial on how to handle errors for a NodeJS + ExpressJS 3 api.I’ve read a lot of questions/answers on SO and read the official ExpressJS guide and still cannot figure out the proper way to do such an important thing. Most of the answers I found were relevant in Express 1 or Express 2, but are not anymore and the ExpressJS Guide just describes something out of context, which makes it really hard to understand.So here’s my use case

  • Lekhnath
    node.js mongodb express mongoose jade
    In my node app I have designation model with following Schema.var DesignationSchema = new Schema({_id : ObjectId,designation : String });And this is embedded in users Schema.var UserSchema = new Schema({fname:String,lname :String,email :String,password :String,designations : [DesignationSchema] });User can select one / many designations from select list. Below is my jade implementation for creating select list;select(name=”designations”) – for(var i = 0; i < designations.length; i++) {option(

  • 580THz
    javascript node.js express
    What is the best way to separate all module dependencies into a new file called dependencies.js, and requiring that file in for example server.js. How do i return all these requires?var express = require(‘express’), stylus = require(‘stylus’), fs = require(‘fs’), https = require(‘https’), app = express();

  • Jiew Meng
    coffeescript express
    I find that exports.index = (req, res) ->res.render “index”,title: “Hello”compiles toexports.index = function(req, res) {return res.render(“index”, { title: “Hello” }) }Something that works with ExpressJS. However, I thought that I could use: exports = index: (req, res) ->res.render “index”,title: “Hello”so that I wont have to type exports.xxx for all routes, but that compiles to var exports; exports = {index: function(req, res) {return res.render(“index”, {title: “Hello”});} };which doesn

  • GreenGiant
    node.js express socket.io
    Excuse my ignorance, day 2 of node.js/socket.ioI’m looking for a way to uniquely identify users for use in a database queuing system. I read a lot about using Express’s session cookie, however I’ve noticed socket.id seems to be an UID that socket.io is already using. Therefore I have been using socket.id to identify my users both in the database, and in creating private “rooms” to communicate with just them.Is this a terrible idea?

  • Trevor Dixon
    javascript node.js cookies express
    I am trying to understand how the cookie middleware works by looking at the source code. This middleware is going to replace the deprecated cookieParser(). https://github.com/jed/cookies/blob/master/lib/cookies.jsNeed some help in explaining the very first sentence:…function Cookies(request, response, keys) {if (!(this instanceof Cookies)) return new Cookies(request, response, keys)… } …What does “!(this instanceof Cookies)” do? Is it checking the “this” is the function itself? What is the

  • Raynos
    jquery ajax node.js express
    Having some trouble getting express to respond properly to my jquery ajax request. The actual posting is working fine, but no matter what I try I cant seem to actually get a data response from my app that I can use. At first it was just posting and hanging constantly, and like a minute later it would respond with an alert that said something like “XML Document loaded” (have no idea where it was coming from) — Anyways, now its giving meSyntaxError: Unexpected token ILLEGALat parse (native)at Inc

  • Nahn
    node.js mongodb express mongoose
    I’m trying to sort via mongoose 3.6.20 and I am receiving some unexpected results.I have a list of companies with a name. At first I thought that maybe it was sorting in a case sensitive way. Which based on articles, I expect was true.I’m now using a virtual property to down case the sort field. However, I’m still getting unexpected results.CompanySchema.virtual(‘name_lower’).get(function(){return this.name.toLowerCase(); });and when I sortCompany.find().sort({ name_lower: 1 });I’m getting it in

  • Zweihander
    json backbone.js mongoose express
    I’ve got the following embedded docs Mongoose model definedvar mongoose = require(“mongoose”);module.exports = function(mongoose) {var Schema = mongoose.Schema,chapters, articles;Articles = new Schema({identity: Number,order: Number,quick_title: String,full_title: String,last_edited: Number,contributor: [String],content: String,video_link: String,presentation_link: String,question_id: [Number],show_in_chapter: Boolean,summary_text: String,summary_image: String});chapters = new Schema({order: Num

  • tonymx227
    node.js express socket.io
    I have a problem with Express.io: I try to create a chat but I am not able to use the Broadcast method.No error message, but nothing happens.app.jsvar express = require(‘express.io’), index = require(‘./routes/index.js’), http = require(‘http’), path = require(‘path’);var app = express();app.configure(function(){//configure options });app.http().io();app.get(‘/’, index.index);app.io.route(‘ready’, function(req) {req.io.broadcast(‘newUser’); });app.listen(app.get(‘port’), function(){console.log(“

  • ken
    ember.js
    In the debugger it’s easy enough to get at the class definitions of objects I’ve created by typing in the App.ClassName.prototype. Ok not hugely interesting but still good when you’re first feeling around in the “Ember dark”. What about instances though? That’s really what I want access to. If my app has moved to the ActivitiesByDateRoute and instantiated the ActivitiesByDateController then there must be a instance of ActivitiesByDateController but what container is it stored in? I thought maybe

  • jeckyll2hide
    ember.js ember-data
    I have the following model:App.Service = DS.Model.extend(App.NodeMixin, {properties : DS.belongsTo(‘App.ServiceProperties’),…. });properties is an embedded property:App.Adapter.map(‘App.Service’, {…properties: {embedded: ‘always’} });Whenever I want to create a new service, I create also the properties:this.transaction = this.get(‘store’).transaction(); var entry = this.transaction.createRecord(App.Service, {}); var properties = App.ServiceProperties.createRecord(); entry.set(‘properties’, p

  • alalani
    ruby-on-rails ember.js mongoid ember-data
    I have two models in Mongoid: Teams and Players where Players is embedded_in Teams. On the front end we use Ember.js and every time I add a new Player to a team I save the parent record (ie. the Team). Every time I update the parent record on the backend in rails I call Team.find(params[:id]).update_attributes(params[:team])Now the problem is each time I call update_attributes all the embedded objects (ie the players) get recreated with new ids and saved in the team. This is unexpected since I w

  • Abdull
    ember.js ember-data
    Ember Data’s documentation discusses different events in a model instance’s lifecycle. I would expect that the didUpdate event is triggered whenever any of a model instance’s properties change. But my experiments don’t show this behavior. Here is a JS Bin example: http://jsbin.com/uziwam/9/edit In that example, you can see that I register handlers on the “ren” model instance: I register handlers (console.log(..) messages) for the didLoad and didUpdate events.When starting the code, “ren’s” didL

  • user1984778
    jquery-ui ember.js
    I need an advanced multiselect element (with search function) for my ember application.I like this jQuery-UI Multiselect widget and started with this code:// app.js … App.MultiSelectView = Em.View.extend({didInsertElement: function() {this._super();console.log(“Creating multiSelect element”);$(“#mselect”).multiselect().multiselectfilter();}, }); App.multiSelectView = App.MultiSelectView.create(); …// index.html … <script type=”text/x-handlebars” data-template-name=”mulselect”><sel

  • dgbonomo
    ember.js
    (This is a double-post of my identical question on the EmberJS Discuss forums.)When a handlebars template {{value}} is somewhere where the browser doesn’t reasonably expect plain text, such as a <table>, it seems to behave in unexpected ways. I’ve created an example page with source and included it below. Can anybody explain what is going on or why this happening, and whether or not this behavior is intentional?To clarify, I’m not looking for a quick way around this. I know how to do that

  • Ben
    ember.js state-management
    I’ve setup a State Manager for tracking user login state, based on this answer here: Change Navbar based on login stateHowever, I’d like to take it to the next step and have not only the navbar update according to the state, but the main template itself. I’ve gotten this mostly working so that when you click on the login button it will show you the ‘welcome you’re now logged in message.’ However, if you logout and try to login again, it just shows a blank screen as if it is not correctly re-re

  • HaoQi Li
    ember.js ember-data
    General question: I would like to get an overview of current transaction (currentTransaction) and default transaction (defaultTransaction).Specific question: I’ve been comparing in the Ember controller this.get(‘model’).save() and this.get(‘store’).commit().this.get(‘model’).save() will eventually call Ember-data Store’s get(this, ‘currentTransaction’).commit()., see github.this.get(‘store’).commit() will eventually call Ember-data Store’s get(this, ‘defaultTransaction’).commit(), see github.In

  • Wojciech Bednarski
    javascript ember.js
    I’m trying to call view method from controller, but no idea how to do this. From view I can easily call controller method like this.get(‘controller’).send(‘method’);How to do something like that from controller this.get(‘view’).send(‘method’);?To give you better overview what I’m trying to do.I have application controller Ember.Controller.extend({}) I have application view Ember.View.extend({}) and application template.In application template is login form, when user submit it controller method

  • Jarrod Nettles
    ember.js url-routing client-side javascript-framework
    I’m working on a new client-side only app with the latest version of Ember.js. There is a single PHP page which builds the scripts, css, template files, etc. and delivers it all into index.php. I’m using an htaccess directive so that all requests are rewritten to /index.php. The PHP is only there to conveniently package the Javascript, as far as I’m concerned.Currently, routes in the browser look like this and work just fine./#/about /#/favorites /#/etc /#/posts/5/editHowever, I would like them

Web site is in building