0

I'm trying to make my javascript menu dynamic by pulling existing pages from my mysql database.

I want to do this: Apply php/MySql while loop in javascript object - But in a .js file.

anylinkmenu4.items=[

[" echo looped content here   ", "echo looped content here.php"] ]

If the question above answers the question please let me know because I haven't been able to run php in a .js file.

2
  • 3
    Serve a .php JavaScript file instead of a .js file, or serve it inline, or use Ajax. Commented Nov 6, 2012 at 4:59
  • Thank you minitech. I was able to produce the desired result by changing the .js file to a .php file and echoing the entire js code. Commented Nov 6, 2012 at 5:27

2 Answers 2

0

Call the php file with ajax. See. http://api.jquery.com/jQuery.ajax/

See Using jQuery, JSON and AJAX to populate a drop down

1
  • I'm sure this is useful but it didn't provide me with the answer I was looking for. Commented Nov 6, 2012 at 5:28
0

Serve a .php JavaScript file instead of a .js file, or serve it inline, or use Ajax.

Thanks to minitech for the answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.