将表达后的方法显示给用户的解析结果 [英] displaying the parsed result to user got after form post method

查看:100
本文介绍了将表达后的方法显示给用户的解析结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设 - 我办公室里的人没有那么聪明/我不想用我的下面的任何服务器端口:)


  1. 我的Html文件驻留在本地磁盘中(请考虑跨域的约束和限制解决方案)

  2. 双击时,HTML表单打开并要求输入订单号码
  3. 输入表单并提交表单时,服务器以XML
    的形式返回详细信息注意:对于提交我使用的HTML POST方法,
    Upto第3步一切正常,我得到服务器响应xml作为浏览器的下一页。

现在,
如何解析此响应xml,以便只显示所需的数据

JS提交函数





pre> function submit1()//当我点击表单上的提交按钮时调用
{
var actionFianl =http:// URL(其他数据为giv en作为表单发布方法);
document.form1.action = actionFianl;
document.form1.submit();
}

显示XML数据,从

 <?xml version =1.0encoding =UTF-8?> 


解决方案

所以如果我明白你的问题,由于跨域问题导致的问题。我记得做了这样的事情,并发现Safari的工作,但铬不喜欢它,由于交叉来源的政策。这是一段时间了,我不确定这是否是同样的问题。



如果我正确地理解了你,你想在JavaScript中使用XML,而不是显示raw数据独立。如果Ajax无法使用,想到的是有两个文件。当前的将会包含表单并获取XML。第二个文件包含iframe中的第一个文件,该文件读取iframe的内容,提交表单时可以读取XML。

另一个解决方案可能类似于 node-webkit ,具体取决于应用程序的规模。 Node-webkit是运行Webkit和Node的windows / mac / linux的可执行文件,并在单个上下文中运行它们。也许你可以通过Node服务器获取XML,而不是通过vanilla表单提交。


Assumption - people in my office are not that smart / I dont want to use any server port for my below utlity :)

  1. My Html file resides in the local disk (consider cross domain refrences constraint hile sugessting the solution)
  2. When double clicked , HTML form opens and asks for entering order number
  3. when entered and form is submitted , server responds back with details in the form of XML Note : for submitting i used html POST method , Upto 3rd step everything works fine and i get the server response xml as next page on browser.

Now, How to parse this response xml so that only desired data is shown on the next page when form is submitted on 3rd step , bypassing the raw response from server.

JS submit function

function submit1() // called when i click on submit button on my form
{
 var actionFianl = "http://URL(other data is given as form post method)";
document.form1.action = actionFianl;
document.form1.submit();
      }

And XML data is displayed , starting with

<?xml version="1.0" encoding="UTF-8" ?> 

解决方案

So if I understand your issue, Ajax calls are out of the question due to cross domain trouble. I remember doing something like this and found that Safari worked, but Chrome did not like it, due to cross origin policy. This was a while back and I am not certain if it was the same problem.

If I understand you correctly you want to have the XML in Javascript, instead showing the raw data independently. What comes to mind if Ajax can't be used, is having two files. The current one will have the form included and gets the XML. The second file containing the first file in an iframe, which reads the content of the iframe, when the form is submitted, and is able to read the XML.

Another solution might be something like node-webkit depending on the scale of your application. Node-webkit is an executable for windows/mac/linux which ships Webkit and Node, and runs them in a single context. Maybe you could get the XML through the Node server instead doing it through a vanilla form submit.

这篇关于将表达后的方法显示给用户的解析结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆