dsjq62428 2011-09-28 00:30
浏览 56

通过URL检查并发送变量,无需重定向

i am trying from my main web page to check and in some cases send a variable via URL like this (http://192.168.0.110/CVAL.CGI?A0=1) this is to modify the status of something in my web page depending on the value seen in the url.

  • 写回答

1条回答 默认 最新

  • doulang6013 2011-09-28 00:37
    关注

    Sounds like you need Ajax.

    There are many javascript libraries that can help you with this functionality such as jQuery, Prototype, or one of the many found on this page.

    Hope that is what you are looking for and is helpful. Next time post more specific details so we can answer your question correctly the first time. Specific, detailed examples of what you want to do are also helpful.

    UPDATED: Here is an example using the Prototype Javascript library given your example form:

    new Ajax.Request('/CVAL.CGI?A0=1', {
        method: 'get',
        parameters: { anotherValue: 'something' },
        onSuccess: function(transport) {
            alert(transport.responseText); // this is what the server returned
        }
    });
    

    This would result in a request to /CVAL.CGI?A0=1&anotherValue=something. Whatever CVAL.CGI returns in response to that request, is available from transport.responseText.

    This way, the user never has to leave the page or submit a form but it is all done behind the scenes. Your parameters can be any values you want to send which you can grab from form fields or other user input. You can return responses in JSON to make accessing the return data easier as well. Change method from 'get' to 'post' to do post requests.

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序