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? Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment 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... Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
F1Fan Posted October 13, 2008 Share Posted October 13, 2008 ajax_do('http://' + url_variable + '.com'); Quote Link to comment 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... Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.