xmlhttprequest

Jax-RS and Xmlhttp Communication

淺唱寂寞╮ 提交于 2019-12-23 22:56:48
问题 I have a REST Server in Java JAX-RS and an HTML page. I want to send a JSON array, a username, and an accountID from the HTML page through an xmlhttp POST request by making all of them a single big String so I can use the xmthttp.send() method. The HTML sending code is: function sendData() { var req = createRequest(); var postUrl = "rest/hello/treeData"; var dsdata = $("#treeview").data("kendoTreeView").dataSource.data(); var accID = "onthespot"; var username = "alex"; req.open("post",

Ajax resending XMLHttpRequest

谁说胖子不能爱 提交于 2019-12-23 20:51:02
问题 I've got a client side js/ajax script like this: <p>server time is: <strong id="stime">Please wait...</strong></p> <script> function updateAjax() { xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==3 && xmlhttp.status==200) { document.getElementById("stime").innerHTML= xmlhttp.responseText; } if (xmlhttp.readyState==4) { xmlhttp.open("GET","date-sleep.php",true); xmlhttp.send(); } } xmlhttp.open("GET","date-sleep.php",true); xmlhttp.send(); }

AJAX get custom response headers with CORS

回眸只為那壹抹淺笑 提交于 2019-12-23 20:19:40
问题 My server sends custom headers along with the response. I get the response data alright, but I can't access the custom headers with jQuery's getAllResponseHeaders() or AngularJS $http service. All I get is content-type . When I inspect the request response with DevTools or fiddler, I can see all the custom headers being sent by the server, but I can't get them from xhr. Is there any way to access all the headers? 回答1: OK I got this working after adding allowed headers in my server config

Accessing markLogic from another localhost

情到浓时终转凉″ 提交于 2019-12-23 20:13:28
问题 I am trying to use markLogic as a document repository and to write a client that can access it from my localhost (Apache)... In markLogic, I have created a new REST server (8011) and I now would like to access a markLogic database from the client with a (hopefully simple) HTTP request (actually using jQuery $.ajax). However, the CORS problem rears its ugly head(er). After researching stackoverflow I have modified the $.ajax to include the statement: "crossDomain: true," - however this is not

Multipart formdata POST request just doesn't work in Cypress for me

爷,独闯天下 提交于 2019-12-23 19:03:07
问题 Nothing works for me. If I use cy.request(), I'm unable to send formdata with it which contains a text and an image. So I've to go via XHR route. So, in my command.js I've used the following code to create a command: - Cypress.Commands.add("formrequest", (method, url, formData, done) => { cy.window().then(win => { return new Promise((resolve, reject) => { const xhr = new XMLHttpRequest(); xhr.open(method, url, false); xhr.setRequestHeader("accept", "application/json"); xhr.setRequestHeader(

What to do when an API doesn't allow Access-Control-Allow-Origin

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 18:56:37
问题 I'm driving crazy with all this same-origin-policy thing. When I try to do a request to the Google Maps API I have no problems: var jsonData = $.ajax({ url:"http://maps.googleapis.com/maps/api/geocode/json?address=", dataType:"json", async:true, success: function(json){...} } I think that is because Google Maps API allow Access-Control-Allow-Origin. But when I try to use the openls.geog.uni-heidelberg.de API I get the cross-origin error: var xmlData = $.ajax({ type: "GET", url:"http://openls

Different Behavior of XMLHttpRequest for <input type=“button”> vs. <button>

牧云@^-^@ 提交于 2019-12-23 18:47:59
问题 Consider the following code: index.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <script type="text/javascript" src="script.js"></script> </head> <body> <form> <button id="getInfoButton1"></button> <input type="button" id="getInfoButton2"></input> </form> </body> </html> With the accompanying JavaScript file: script.js window.onload = initAll; var req; function initAll() { document.getElementById("getInfoButton1").onclick =

FF extension - getting xmlhttp.status==0

那年仲夏 提交于 2019-12-23 17:50:30
问题 I'm writing an extension for Firefox and it is using page-mod module to run a JavaScript file containing: function handleServerResponse() { if (xmlHttp.readyState == 4) { if(xmlHttp.status == 200) { //some code } else { alert("Error during AJAX call. Please try again"); } } } var xmlHttp = new XMLHttpRequest(); var txtname = document.getElementById("txtname"); xmlHttp.open("POST","http://localhost:8080/Jelly/GetStuff",true); xmlHttp.onreadystatechange = handleServerResponse; xmlHttp

Is there a way for chrome packaged apps to handle Http BasicAuthentication

a 夏天 提交于 2019-12-23 17:23:29
问题 I'm building a Chrome packaged app called Git Crx and as the name suggests it needs to go network requests to and from remote git repos using HTTPS (smart protocol) BUT if you attempt to do an XHR request to a url that returns 401, the XHR will fail without using the normal browser credentials machinery whereas previously packaged apps would show the browsers normal credentials request UI. Now I think that does makes sense to me now, as Chrome Apps are supposed to be stand alone apps and not

How to log PHP file run with jQuery AJAX in browser console?

北慕城南 提交于 2019-12-23 17:15:02
问题 I have a PHP file that does data processing. It's run by $.ajax() , sometimes on big files that take a long time to process. I need to log some info about the ongoing process in the browser console that is displayed on the go , not just when the PHP file has finished running. From the research I did, I get that there are two difficulties: Getting PHP to spit out something before it's done Getting jQuery/JS to display it on the go To address #1, I've tried: echo "started"."<br>"; foreach