Tag: jquery

如何从节点js读取ajax请求的数据?

我试图从客户端发送数据到服务器(节点js)。 我正在使用ajax。 客户: $("#test_button").on("click",function(){ //alert("shit"); $.ajax( {url: "http://localhost:4000/ajax_check", async: false, type: "POST", data: "{user:balayya,password:hero}", success: function(result){ alert("hooli"); }}); }); 服务器: var app = require('express')(); var express = require('express'); var http = require('http').Server(app); http.listen(process.env.PORT || 4000, function() { console.log('listening on *:4000'); }); app.use(express.static('publuc')); app.get('/', function(req, res) { console.log("new entry page serving"); res.sendFile(__dirname + '/main.html'); }); app.post('/ajax_check', […]

Angular jquery插件 – jQuery没有在插件中定义

我尝试在我的Angular项目中导入jquery-knob插件,所以我通过npm安装了jquery – 工作正常。 现在我想添加jquery旋钮(也通过npm),但我得到这个错误,我认为它在 jquery.knob.min.js Uncaught ReferenceError: jQuery is not defined at eval (eval at webpackJsonp.310.module.exports (addScript.js:9), <anonymous>:1:85) at eval (eval at webpackJsonp.310.module.exports (addScript.js:9), <anonymous>:1:95) at eval (<anonymous>) at webpackJsonp.310.module.exports (addScript.js:9) at Object.155 (jquery.knob.min.js?4d31:1) at __webpack_require__ (bootstrap aa173b5…:52) at Object.351 (addScript.js:10) at __webpack_require__ (bootstrap aa173b5…:52) at webpackJsonpCallback (bootstrap aa173b5…:23) at scripts.bundle.js:1 在.angluar-cli.json "scripts": [ "../node_modules/jquery-knob" […]

使用嵌套或条件的多个where(或AND)?

如何在mongodb中使用水线ORM在Sailjs中进行查询,使用多个AND条件,每个条件都具有嵌套OR条件。 一个示例MySQL查询将是: SELECT * FROM Users WHERE (score IS NULL OR activity IS NULL) AND (invited IS NULL OR invited_by IS NULL) 使用多个.where()似乎不工作,也使用OR prop中的所有条件销毁逻辑。 任何解决scheme?

ReferenceError:在Ajax调用尝试redirect用户之后没有定义窗口

我是新来的EJSexpression。 我试着做一个Ajax的后请求提交给数据库使用的值。 $.ajax({ type: 'POST', url: '/register', data: user, success: function(data){ console.log(data); return data; } }); return false; 这个调用是成功的,然后控制转到调用函数 var sess; app.post('/register',urlencodedParser,function(req,res){ sess=req.session; var newUsr=Users(req.body).save(function(err,data){ if(err) throw err; console.log(" back from ajax with data :::; " + data); console.log("step1 cleared"); sess.registered=true; }); console.log("step2 cleared"); location.window.href = '/index2'; }); 我希望用户在注册成功后能看到索引页,但是我得到了下面的错误。 ReferenceError: location is not defined 我觉得位置对象是不是在节点,因此这个错误,但我不知道如何解决这个问题,请build议

为什么这个Cheerio属性select器不工作?

我想使用通常在jQuery中find的以下select器来创build一个可以在其子节点上工作的函数: var useroverviewHook = $("div[data-pnref='overview'] *[data-overviewsection]"); 但是,它不在Cheerio工作。 Nodejs控制台正在报告 console.log($(useroverviewHook).length) is 0 即使在浏览器中testing时,该值不是0,存在多个元素。 首先,我认为内容是dynamic的,但如果我输出 res.writeHead(200, {'Content-Type': 'text/plain'}); res.write(html); 数据概览部分在那里。 但是cheerio说不是。

在Angular 2 cli项目中集成bootstrap

面对将Bootstrap与angular色2 cli集成的问题。 我是新的angular2 CLI请指导我,纠正我,如果我正在做我的步骤错了。 提前致谢。 步骤如下: 1. npm install bootstrap @ next –save 2.修改.angular-cli.json文件 这是我修改的: "styles": [ "../node_modules/bootstrap/dist/css/bootstrap.css", "styles.scss" ], "scripts": [ "../node_modules/jquery/dist/jquery.js", "../node_modules/tether/dist/tether.js", "../node_modules/bootstrap/dist/js/bootstrap.js" ], 用ng服务重新启动应用程序 发生错误如下: 在多脚本加载器中出现错误!./〜/ jquery / dist / jquery.js script-loader!./〜/ tether / dist / tether.js script-loader!./〜/ bootstrap / dist / js / bootstrap.js找不到模块:Error:无法parsing'/ Users / sagarbhanushali / projectangularcliyoutube / myProject […]

如何在浏览器刷新上加载特定的页面

我有一个HTML页面,当按下“ Reset ”button时,我总是加载一个特定的页面( control.html )。 我不想要Resetbutton,而是在浏览器刷新时执行相同的操作。 我怎么做? 似乎没有浏览器刷新的键码在整个浏览器中是通用的。 另外这个post是没有帮助的。 我正在使用一个nodejs服务器。 服务器代码如下: var http = require('http'); var fs = require('fs'); var url = require("url"); var path = require("path"); var ent = require('ent'); //below creates the server functionality. //You shouldn't need to change this. var server = http.createServer(function(request, response) { var uri = url.parse(request.url).pathname , filename = […]

如何validation数据库生成的问卷

我有从数据库生成的node.js问卷,现在的问题可以是任何“多选,单选,是 – 否和文本”的随机typesvalidation应该是简单的检查是每个问题的答案。 我知道如何validation表单,但问题是,我的表单有名称,姓氏和电子邮件对话框,所以我需要第一部分在jQuery /buttonid="show-dialog" JavaScriptvalidation,以及我的对话名称,姓氏和第二个button上的电子邮件。 我的看法(start.ejs)看起来像这样: <!DOCTYPE html> <html> <head> <title><%= title %></title> <link rel='stylesheet' href='/stylesheets/style.css' /> <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"> <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css"> <script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script> <script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script> </head> <body> <h1><%= title %></h1> <form name="questionsForm" id="questionsForm" method="post" action="/save"> <% pitanja.forEach(function(pitanje) { %> <input type="hidden" name="pitanje_id" value="<%= pitanje.id %>" > <input type="hidden" name="upitnik_id" […]

如何从ReactJS组件中删除“onClick”属性?

我刚开始使用ReactJS和ReactJS 。 我不太清楚一些东西。 render( ) { return ( <div> <img src={this.props.pic} onclick={this.props.cb()} class="af1" /> </div> ); } 以上是我的App组件的渲染方法。 我想在第一次点击图像后删除onClick属性,并禁用图像( not able to click again )10秒左右(请build议我是否有更好的方法来暂时禁用点击图像)。 这是一个很好的解决scheme吗? 为什么不能在Chrome的开发者控制台中看到onclick attrib? 我真的开始喜欢学这个东西,我迷路了。

Ajax DELETE请求似乎只删除列表中的第一个项目

我一直在重复使用这些代码进行不同的项目,但是对于这个项目来说,这似乎不起作用。 我正在使用Express和Mongoose,并使用它来存储大学课程详细信息列表。 这是Schema。 exports = module.exports = function(app, mongoose) { var moduleSchema = new mongoose.Schema({ pivot: { type: String, default: '' }, module_name: { type: String, required:true}, module_code: {type: String, required: true}, description: {type: String} }); moduleSchema.plugin(require('./plugins/pagedFind')); moduleSchema.index({ pivot: 1 }); moduleSchema.index({ module_name: 1 }); moduleSchema.index({ module_code: 1 }); moduleSchema.index({ description: 1 }); moduleSchema.index({ search: […]