xmlhttprequest

GET request working on postman but not in browser

走远了吗. 提交于 2020-02-08 10:00:30
问题 I have encountered a strange issue with a GET request that I am stuck on. I am calling a GET request from my ASP.Net application that works fine in postman but does not hit my userGETReq.onload. function getUser(username){ userGETReq.open("GET", userURL + "/" + username); userGETReq.send(); userGETReq.onload = () => {if(userGETReq.status === 200){//cool stuff }} I am running on a localhost in the browser - the function to start this is being called from a form that returns false. <form

JS AJAX

自闭症网瘾萝莉.ら 提交于 2020-02-07 04:54:08
1. ajax与XMLHttpRequest 什么是XMLHttpRequest 一种支持异步请求的技术,是ajax的核心 XMLHttpRequest的作用 向服务器提出请求并处理响应而不阻塞用户 可以在页面加载后进行局部页面更新 如何使用ajax 创建XMLHttpRequest异步调用对象 创建一个新的HTTP请求,并指定该HTTP请求的方法URL 设置响应HTTP请求状态变化的函数 2. XMLHttpRequest对象 简单版本 var xmlhttp ; if ( window . XMLHttpRequest ) { xmlhttp = new XMLHttpRequest ( ) ; } else { xmlhttp = new ActiveXObject ( 'Microsoft.XMLHTTP' ) ; } 全面版本 function createXHR ( ) { if ( typeof XMLHttpRequest != "undefined" ) { return new XMLHttpRequest ( ) ; } else if ( typeof ActiveXObject != "undefined" ) { var xhrArr = [ 'Microsoft.XMLHTTP' , 'MSXML2.XMLHTTP.6.0' , 'MSXML2

CORS 'Allow-Credentials' Nodejs/Express

若如初见. 提交于 2020-02-05 06:22:32
问题 My project is running on Node with an Express backend. I'm trying to query my Arango database clientside with Arangojs. ArangoDB is running on Docker on Digital Ocean. I have no issues querying my database serverside, however I get the following error on page load: Failed to load http://0.0.0.0:8529/_db/database/_api/cursor: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Credentials' header in the response is 'false' which must be 'true

No 'Access-Control-Allow-Origin' header is present. XmlHttpRequest

限于喜欢 提交于 2020-02-05 05:19:47
问题 I got XmlHttpRequest object, and i'am trying to send long html data string to Asp Net Core, to make out of it content PDF file. But still getting CORS policies. Even-though i have "Access-Control-Allow-Origin" in my header, it still an issue for me. Already tried everything with CORS. Installed cors for Asp net Core, nothing changed. Everything works fine if i use my HTML document from local. Full error: Access to XMLHttpRequest at 'https://.../getInfoWindowPdf?' from origin 'https://...' has

Ajax

…衆ロ難τιáo~ 提交于 2020-02-05 00:13:09
一、简介 “Ajax”这个名字是在2005年2月,Adaptive Path的Jesse James Garrett在他的文章Ajax:A New Approach to Web Application中创造。而Ajax这项技术,是Google在Google Labs发布Google Maps和Google Suggest后真正为人所认识。 Ajax被认为是(Asynchronous JavaScript and XML的缩写)。现在,允许浏览器与服务器通信而无须刷新当前页面的技术都被叫做Ajax. Ajax:一种不用刷新整个页面便可与服务器通讯的办法。 不用刷新整个页面便可与服务器通讯的办法: Flash Java applet 框架:如果使用一组框架构造了一个网页,可以只更新其中一个框架,而不必惊动整个页面 隐藏的iframe XMLHttpRequest:该对象是对 JavaScript 的一个扩展,可使网页与服务器进行通信。是创建 Ajax 应用的最佳选择。实际上通常把 Ajax 当成 XMLHttpRequest 对象的代名词 Ajax并不是一项新技术,它实际上是几种技术,每种技术各尽其职,以一种全新的方式聚合在一起 服务器端语言:服务器需要具备向浏览器发送特定信息的能力。Ajax与服务器端语言无关。 XML (eXtensible Markup Language

Using gettext with Javascript from PHP via XMLHttpRequest

痴心易碎 提交于 2020-02-03 18:54:51
问题 I have an application mainly written in PHP. The translations are done using gettext(). There is a small JavaScript part which also contains strings to be translated. I wrote this simple but working method using XMLHttpRequest: function gettext(string_to_translate) { var filename = get_php_script_folder() + 'gettext.php?string_to_translate=' + string_to_translate; var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", filename, false); xmlhttp.send(); if (xmlhttp.status === 200) { var

Using gettext with Javascript from PHP via XMLHttpRequest

孤人 提交于 2020-02-03 18:53:49
问题 I have an application mainly written in PHP. The translations are done using gettext(). There is a small JavaScript part which also contains strings to be translated. I wrote this simple but working method using XMLHttpRequest: function gettext(string_to_translate) { var filename = get_php_script_folder() + 'gettext.php?string_to_translate=' + string_to_translate; var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", filename, false); xmlhttp.send(); if (xmlhttp.status === 200) { var

AJAX技术中XMLHttpRequest对象学习笔记

时光总嘲笑我的痴心妄想 提交于 2020-02-03 05:52:58
在AJAX使用的技术中,最核心的技术就是XMLHttpRequest,它是一个人具有应用程序接口的JavaScript对象,能够使用超文本传输协议(http)连接一台服务器。XML的英文释义是可扩展标记语言,它提供了用于描述结构化数据的格式,适用于不同应用程序之间的数据交换。XMLHttpRequest的数据通常采用XML格式。 1.XML 文档结构 如下图所示是一个简单的XML文档: 在上面的XML文档代码中,第一行是XML声明。其中为根元素,其它的都是该元素的子元素。 2.XML语法要求 1.XML文档必须有一个顶层元素,其它元素必须嵌入顶层元素中 2.每个元素必须有结束标签 3.区分大小写 4.元素可以包含属性,但是属性值必须用单引号或双引号括起来。在一个元素节点中,属性名不能重复。 XML的注释 XML中的注释结构为 ,是对文档结构内容的解释说明。该部分不属于XML文档内容,所以XML解释器不会处理该内容。, 来源: CSDN 作者: Tony_20 链接: https://blog.csdn.net/Tony_20/article/details/104142233

AJAX request progress percentage log

吃可爱长大的小学妹 提交于 2020-02-03 00:46:10
问题 I read content from http://www.dave-bond.com/blog/2010/01/JQuery-ajax-progress-HMTL5/ and i try make that ajax progress bar on my own site, but in console i have only xhr response when php script is full completed. My part of JS code: $('#userSaveData').on('click', function(e){ e.preventDefault(); var $form = $(this).closest('form'); var route = $form.attr('action'); var form_data = $form.serializeObject(); $.ajax({ xhr: function() { var xhr = new window.XMLHttpRequest(); //Upload progress

AngularJS: How to execute a controller function AFTER completion of AJAX call in a service?

好久不见. 提交于 2020-02-02 04:06:28
问题 Here's my code in the service. this.loginUser = function(checkUser) { Parse.User.logIn(checkUser.username, checkUser.password, { success: function(user) { $rootScope.$apply(function (){ $rootScope.currentUser = user; }); } }); }; Here's my code in the controller: $scope.logIn = function(){ authenticationService.loginUser($scope.checkUser); console.log($scope.currentUser) }; So, what I want to do is, execute some code AFTER the completion of AJAX call, whose success function sets the value of