xmlhttp

Delphi 2007 IXMLHTTPRequest Time out issue

匿名 (未验证) 提交于 2019-12-03 09:10:12
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm using Delphi 2007 and have imported MSXML6_TLB. I'm using IXMLHTTPRequest object to send request to server. Example: XMLHttp := CoXMLHTTP60.Create; try XMLHttp.open('POST', URL, False, EmptyParam, EmptyParam); XMLHttp.setRequestHeader('Content-Type', 'text/xml;charset=UTF-8'); XMLHttp.send(reqXMLDoc.XML.Text); //--> timeout in 10 secs if (XMLHttp.readyState = 4) then StrStream.WriteString(UTF8Encode(XMLHttp.responseText)); XMLHttp.send() keeps timing out if response takes more than 10 secs. I've tested this in other systems and it works

ajax测试Demo以及json简单的转化

女生的网名这么多〃 提交于 2019-12-03 06:31:15
Ajax是局部刷新,并不影响页面其他的操作 实例1:本测试是演示利用Ajax在一个页面播放视频,点击赞和踩按钮,视频不会受影响, 新建一个ajaxTest.html页面 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript" src="js/ajax.js"></script> <script type="text/javascript"> function zan() { var xmlhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');//创建xmlhttp对象,考虑兼容性 xmlhttp.open("POST", "AjaxTest.ashx?action=Zan", true);//准备向服务器发出post请求 xmlhttp.onreadystatechange = function () { if (xmlhttp

封装原生JavaScript的ajax

时光毁灭记忆、已成空白 提交于 2019-12-03 04:35:41
function obj2str(data) { data = data || {}; // 如果没有传参, 为了添加随机因子,必须自己创建一个对象 data.t = new Date().getTime(); var res = []; for (var key in data){ //在URL中是不可以出现中文的,如果出现了中文需要转码,可以调用encodeURIComponent方法,URL中只可以出现字母、数字、下划线 res.push(encodeURIComponent(key)+"="+encodeURIComponent(data[key])); } return res.join("&"); } function myAjax(option){ var params = obj2str(option.data);//key=value&key=value; var xmlhttp,timer; if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else{// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } if

How to load a PHP page into a div with jQuery and AJAX?

匿名 (未验证) 提交于 2019-12-03 02:50:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to write a function that will call getproduct.php?id=xxx when clicked. I can get the innerHTML portion to appear, but how do I also call the php page that actually does the work? var id = id; document.getElementById("digital_download").innerHTML = "Downloading...Please be patient. The process can take a few minutes."; url = getproduct.php?id=id; 回答1: You can do it with jQuery for example. var id = 1; $('#digital_download').html('Downloading...'); // Show "Downloading..." // Do an ajax request $.ajax({ url: "getproduct.php?id="+id

why this JavaScript method return undefined?

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: in this code this method return undefined despites alert statement print a value ? function getNearestPoint(idd) { var xmlhttp; var result; if(window.XMLHttpRequest) xmlhttp=new XMLHttpRequest(); else xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { result= xmlhttp.responseText; alert(result); } } xmlhttp.open("GET","ajax_get_nearest_location.php?id="+idd +"&radius=1",true); xmlhttp.send(); return result; } 回答1: result isn't defined at that point, it

Parsing JSON data from a URL

匿名 (未验证) 提交于 2019-12-03 02:16:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to create function that can parse JSON from a url. Here's what I have so far: function get_json(url) { http.get(url, function(res) { var body = ''; res.on('data', function(chunk) { body += chunk; }); res.on('end', function() { var response = JSON.parse(body); return response; }); }); } var mydata = get_json(...) When I call this function I get errors. How can I return parsed JSON from this function? 回答1: Your return response; won't be of any use. You can pass a function as an argument to get_json , and have it receive the result.

Embedded Jetty 9 handle one request at a time

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am using jetty 9 in embedded mode and even though i have given a threadpool of 500 the server still just handle one request at a time. What am i missing ? JAVA CODE: // here i expect all thread name log to print instantaneously but they print one by one public class Main { public static void main(String[] arg) throws Exception { ExecutorThreadPool executorThreadPool = new ExecutorThreadPool(Executors.newFixedThreadPool(500)); final Server server = new Server(executorThreadPool); final ServerConnector connector0 = new ServerConnector(server

NETWORK_ERR: XMLHttpRequest Exception 101

匿名 (未验证) 提交于 2019-12-03 01:33:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm having an AJAX problem in Chrome, giving the following error: Uncaught Error: NETWORK_ERR: XMLHttpRequest Exception 101 This is my code: function IO(filename) { if (window.XMLHttpRequest) { // Mozilla, Safari,... xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { } } } xmlhttp.open("GET", filename+"?random="+Math.floor(Math.random()*100000001), false); xmlhttp.send(); if(xmlhttp

XMLHttpRequest cannot load Cross origin requests are only supported for HTTP

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: found an exception 101 in getting data from XML file:XMLHttpRequest cannot load file:///C:/Users/zaid/Desktop/xml/cd_catalog.xml. Cross origin requests are only supported for HTTP. <script type="text/javascript"> if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET","xml/cd_catalog.xml",false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.write("<table border='1'>"); var x=xmlDoc

回调函数的使用

匿名 (未验证) 提交于 2019-12-03 00:41:02
对JavaScript不太清楚,这次知道了回调函数的使用,记录一下。 简单来说,就是把回调方法作为一个参数,传递给另一个方法,然后在那个方法里面执行完一定操作,调用那个方法。这样就实现了回调。 例如: 需要被回调的方法: function callback(a) { console.log( ‘回调函数结果:‘+ a); } 把该回调方法传入另一个方法,在该方法里面调用该回调方法。 function invokeMethod(params,callback) { console.log( ‘接下来就要执行回调方法了‘ ); callback(params); } 最后:执行invokeMethod的时候,传入回调方法和相应参数,就能实现效果。 invokeMethod(‘测试回调方法‘,callback) 效果: 起始上一节里面的Ajax封装就是如此,把回调方法作为参数传入Ajax调用方法,Ajax在获取完数据后,在Ajax方法里面间接调用了回调方法。 Ajax执行方法: function createXMLRequst(){ try { return new XMLHttpRequest(); } catch (e) { try { return new ActiveXObject("Msxml2.XMLHTTP" ); } catch (e){ try { return new