开发者

Check and send variables via URL without redirection

i am trying from my main web page to check and in some cases send a variable via URL like this (http://192.168开发者_Go百科.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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜