I've an issue with the same piece of code running fine on my live website but not on my local development server.
我在我的实时网站上运行正常但在本地开发服务器上运行的相同代码片段存在问题。
I've an Ajax function that updates a div. The following code works on the live site:
我有一个更新div的Ajax函数。以下代码适用于实时网站:
self.xmlHttpReq.open("POST", PageURL, true); self.xmlHttpReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); self.xmlHttpReq.setRequestHeader("Content-length", QueryString.length); //..update div stuff... self.xmlHttpReq.send(QueryString);
When I try to run this on my local machine, nothing is passed to the QueryString.
当我尝试在本地计算机上运行它时,没有任何内容传递给QueryString。
However, to confuse matters, the following code does work locally:
但是,为了混淆事项,以下代码在本地工作:
self.xmlHttpReq.open("POST", PageURL+"?"+QueryString, true); self.xmlHttpReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); //..div update stuff.. self.xmlHttpReq.send(QueryString);
But, I can't use the code that works on my local machine as it doesn't work on the live server (they've changed their policy on querystrings for security reasons)!
但是,我无法使用在本地计算机上运行的代码,因为它在实时服务器上不起作用(出于安全原因,他们已经在查询字符串上更改了它们的策略)!
I can alert the Querystring out so I know it's passed into the function on my local machine. The only thing I can think of is that it's a hardware/update issue.
我可以提醒Querystring,所以我知道它被传递到我本地机器上的函数。我唯一能想到的是它是硬件/更新问题。
Live Site is running IIS 6 (on a WIN 2003 box I think)
Live Site正在运行IIS 6(在我认为的WIN 2003盒子上)
Local Site is running IIS 5.1 (On XP Pro)
本地站点正在运行IIS 5.1(在XP专业版上)
Are there some updates or something I'm missing or something?
是否有一些更新或我缺少的东西或什么?
2 个解决方案
#1
1
Is there a reason you're explicitly setting the Content-Length
header in the first example? You... shouldn't need to do this, and i wouldn't be surprised to find it causing problems.
您是否有理由在第一个示例中明确设置Content-Length标头?你......不应该这样做,我不会惊讶地发现它会导致问题。
Oh, and check your encoding routine. The rules are not quite the same for querystrings and POSTed form data.
哦,检查你的编码程序。查询字符串和POST表单数据的规则并不完全相同。
#2
0
I would guess that Shog9 is right, and that IIS 6 i smart enough to ignore your request and send the correct headers, while 5.2 throws an error.
我猜想Shog9是正确的,IIS 6我足够聪明,可以忽略你的请求并发送正确的标题,而5.2会抛出错误。
#1
1
Is there a reason you're explicitly setting the Content-Length
header in the first example? You... shouldn't need to do this, and i wouldn't be surprised to find it causing problems.
您是否有理由在第一个示例中明确设置Content-Length标头?你......不应该这样做,我不会惊讶地发现它会导致问题。
Oh, and check your encoding routine. The rules are not quite the same for querystrings and POSTed form data.
哦,检查你的编码程序。查询字符串和POST表单数据的规则并不完全相同。
#2
0
I would guess that Shog9 is right, and that IIS 6 i smart enough to ignore your request and send the correct headers, while 5.2 throws an error.
我猜想Shog9是正确的,IIS 6我足够聪明,可以忽略你的请求并发送正确的标题,而5.2会抛出错误。