Tag: jquery

如何在量angular器中进行HTTP GET + POST请求

我面临着在量angular器中发送HTTP请求的问题。 实际上,我需要在UI中执行一些操作后检查数据库中的数据。 这将是非常有用的,如果我能够使用JQuery做到这一点,但我无法find如何在量angular器内使用JQuery的方法。 需要帮忙 !! 实际上,我们尝试使用如下所示的NODEJS库,但是面临着一些问题。 var http = require('http'); var json_data; http.get('SiteUrl', function(response) { var bodyString = ''; response.setEncoding('utf8'); response.on("data", function(chunk) { bodyString += chunk; }); response.on('end', function() { json_data = bodyString; console.log("1—->"+json_data); }); }).on('error', function(e) { console.log("There is an error in GET request"); }); console.log("2—->"+json_data); debugging完成后,我们发现问题在于,Protractor并没有等待HTTP请求完成,只是传递。 我们先在控制台中得到“2 —->”,然后是“1 —->”。

使用Express 4在Node.js中全局处理exception的最佳方法是什么?

AS我们在asp.net MVC中有Exceptionfilter,在express.js中我们有类似的function吗? 我试过以下文章,但没有find所需的解决scheme。 http://www.nodewiz.biz/nodejs-error-handling-pattern/ 我也尝试了下面的app.js process.on('uncaughtException', function (err) { console.log(err); }) 参考文章: http : //shapeshed.com/uncaught-exceptions-in-node/ 任何帮助将是可观的。

如何使用节点js将消息从web服务器推送到浏览器

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <link rel="stylesheet" href="css/animate.css"> <link rel="stylesheet" href="css/style.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" > $(document).ready(function() { $("#notificationLink").click(function() { $("#notificationContainer").fadeToggle(300); $("#notification_count").fadeOut("slow"); return false; }); //Document Click $(document).click(function() { $("#notificationContainer").hide(); }); //Popup Click $("#notificationContainer").click(function() { return false }); }); </script> <style> body{background-color:#dedede;font-family:arial} #nav{list-style:none;margin: 0px; padding: 0px;} #nav […]

用于node.js和jquery web的UI

node.js (考虑一个web应用程序)是否有任何首选的UI框架? 或者这是使用node.js的正交问题? jQuery很好,是jQuery UI最常用的带有jQuery引擎的UI框架吗? 你能指点我其他的select吗?

用于组织大型JavaScript应用程序的工具和最佳实践

我正在开发相当复杂的webapps /仪表板,主要是在Javascript中。 我喜欢在服务器上使用mongo和node,但是在客户端通常会有特定于应用程序的混乱的库和脚本。 我目前的项目包括bootstrap , jquery , jquery-ui , D3 , 传单 , 交叉filter和一些晦涩的东西的组合,这是公平的说,尽pipe应用程序是真棒,代码已成为邪恶的混乱。 特别是D3和crossfilter的代码是相当详细的,例如参见官方crossfilter演示的源代码。 所以这个问题: 组织大型javascript应用程序的好工具和最佳实践是什么? 我已经避免了全局variables,并尝试用闭包来组织命名空间,但是恐怕我需要一些比这更多的结构。 在服务器上有npm,这是相当不错的,但有什么类似的浏览器? 我已经看了require.js , backbone.js和coffeescript ,但是我不太确定这些是否真的能解决问题或者只是增加复杂性。

为什么一个<image>标签被jQuery改变了<img>标签,在chrome中

我使用jQuery来控制chrome中的SVG文件, $('svg #lotsofimage').append("<image xlink:href='" + conf[thing].base + "' width= '" + conf[thing].width + "px' height= '" + conf[thing].height + "px' x='" + thing_x + "pt' y='" + thing_y + "pt' ></image>"); 但是我打开了开发工具,它显示如下: <img xlink:href="xxxx" width="xxxx"> <image></image>was instead of <img /> 如何处理?

正则expression式从数据获取电子邮件ID

是新的常规experssion我有以下数据从这我想要得到唯一的电子邮件ID.How是可能的使用正则expresison commit 01 emailid: Tests <tests@gmail.com> Date: Wed Jun 18 12:55:55 2014 +0530 details commit 02 emailid: user <user@gmail.com> Date: Wed Jun 18 12:55:55 2014 +0530 location commit 03 emailid: Tests <tests@gmail.com> Date: Wed Jun 18 12:55:55 2014 +0530 france24 commit 04 emailid: developer <developer@gmail.com> Date: Wed Jun 18 12:55:55 2014 +0530 seloger 从这个使用常规experssion如何retirve tests@gmail.com,user@gmail.com,developer@gmail.com

Express和Nodejs:调用外部API的最佳方式

我是Express和Nodejs的新手。 我正在尝试调用一个外部API来在页面上构build数据。 有没有办法从expression本身调用外部API(我知道我可以使用HTTP模块来做到这一点),但要确认是最好的方法。 还有一次,我得到了JSON回来,我怎么把它传递给视图。 现在我已经做了一个解决方法,只需加载视图(只是标题)与expression和jQuery的ajax调用API和填充数据。

AngularJS:无法发送POST请求与适当的CORS头

我正在使用AngularJS创build一个Web应用程序。 为了testing它,我使用angular-seed模板在NodeJS服务器上运行应用程序。 在这个应用程序中,我需要通过POST请求发送一个JSON消息到另一个主机 ,并得到响应,所以,我正在使用CORS 。 我的请求是通过实现一个使用AngularJS http服务的服务完成的 (我需要$ http提供的抽象级别,所以我不使用$ resource )。 在这里,我的代码。 请注意, 我修改了$ httpProvider来告诉AngularJS使用适当的CORS头文件发送它的请求 。 angular.module('myapp.services', []). // Enable AngularJS to send its requests with the appropriate CORS headers // globally for the whole app: config(['$httpProvider', function($httpProvider) { $httpProvider.defaults.useXDomain = true; /** * Just setting useXDomain to true is not enough. AJAX request are […]

如何为passportjs使用jquery / ajax数据

如果我使用表单字段action="/login", method="post"发送一个login请求,它工作得很好。 类似于这里或这里可用的代码。 但是,如果我使用jquery/ajax发送相同的信息,那么护照似乎不起作用。 没有实际的login通过护照发生,但ajax调用给出了一个令人误解的成功消息。 以下是不工作。 虽然我得到“login成功”的消息,login并没有真正发生。 $('#login_button').click(function () { var email = $('#email').val(); var password = $('#password').val(); alert ('email/pass:' + email + ", " + password); $.ajax({ type: "POST", url: "/login", data: { email: email , password: password }, dataType: 'html' }) .done(function () { console.log("http request succeeded"); alert("login success"); }); }); 我需要使用ajax方法,以便在成功login后在客户端执行一些有用的操作。 例如,启动socket.io […]