开发者

Function to pass javascript variables to a php file via a GET or POST?

I've got the following function

function make(point, name, message, type, file, id, lat, lng)

I want this function to pass all of these Javascript variables to a php file which would open in a window when a link is pres开发者_运维百科sed how would I do this?


window.open('path/to/php?point=' + point + '&name=' + name); // etc for all other vars

make sure the values of your variables are urlsafe, i'd urlencode them with:

encodeURIComponent(variable);

Edit re your comment

<a href="#" onclick="make(vars, go, here); return false;">Click me!</a>

but if thats all you want, you might as well just have the link open in a blank window:

<a href="path/to/php?point=foo&etc=bar" target="_blank">Click me!</a>

It depends if make() is doing something else other than opening a window, i suspect so?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜