theagent Posted October 13, 2008 Share Posted October 13, 2008 Hi, I'm using this AJAX function here: http://www.devpapers.com/article/328. I don't think that's important for my question, however. I'm trying to do something like this: ajax_do('http://www.variable.com'); "Variable" is a JavaScript variable. I have to embed it in the link somehow... any ideas? Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/ Share on other sites More sharing options...
F1Fan Posted October 13, 2008 Share Posted October 13, 2008 Is this code you're posting PHP or JS? Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664123 Share on other sites More sharing options...
theagent Posted October 13, 2008 Author Share Posted October 13, 2008 Is this code you're posting PHP or JS? The code is in a JavaScript (.js) file. I can't really use PHP in what I'm doing here. I'd like to embed a JavaScript variable in the link as shown. Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664134 Share on other sites More sharing options...
CroNiX Posted October 13, 2008 Share Posted October 13, 2008 ajax_do(url_variable); or ajax_do('http://' + url_variable); depending on how your urls are stored... Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664139 Share on other sites More sharing options...
theagent Posted October 13, 2008 Author Share Posted October 13, 2008 ajax_do(url_variable); or ajax_do('http://' + url_variable); depending on how your urls are stored... ajax_do('http://' + url_variable); Unfortunately, this creates "http://url_variable" and it treats url_variable like a string rather than a variable. Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664148 Share on other sites More sharing options...
F1Fan Posted October 13, 2008 Share Posted October 13, 2008 ajax_do('http://' + url_variable + '.com'); Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664153 Share on other sites More sharing options...
CroNiX Posted October 13, 2008 Share Posted October 13, 2008 I assumed that you knew the variable you were using... Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664157 Share on other sites More sharing options...
theagent Posted October 13, 2008 Author Share Posted October 13, 2008 I assumed that you knew the variable you were using... Oh yes, I substituted my own variable in. But I'm running into more problems -- perhaps its something else with my code. I'll write back if the code you gave is for sure the problem. Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664160 Share on other sites More sharing options...
CroNiX Posted October 13, 2008 Share Posted October 13, 2008 You should post some more examples of what your variable would be holding... Like: http://www.myexample.com anotherexample.net etc. Are they all the same format? Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664169 Share on other sites More sharing options...
theagent Posted October 13, 2008 Author Share Posted October 13, 2008 I found out my problem was in another area of my code. The code you supplied works fine. Thanks CroNiX and F1Fan! Link to comment https://forums.phpfreaks.com/topic/128232-solved-please-help-variable-in-a-link/#findComment-664173 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.