Using javascript in WordPress
-
Hi,
A while back I migrated a whole bunch of HTML pages into pages on a WordPress blog. I eventually solved all the problems (often thanks to people here), but I find I still have one javascript problem.
At then end of every page I had a form which consisted of a simple opportunity to feedback by selecting one of three radio buttons. A javascript file responded when a button was pressed, called a php file and posted the page name and the feedback (2, 1 or 0 for good, indifferent or bad) to my MYSQL database.
The structure of the javascript file was simple:
First, a response thanking the visitor for giving feedback. Second a Try-Catch error trapping routine testing for new XMLHttpRequest(), Third, calling the php file to post to the database.
However running the same javascript file in WordPress gives me the initial response, but nothing more. I am a total javascript novice, but I presume the second section is no longer working. It is of the form:
var request = false; try { request = new XMLHttpRequest(); } catch (failed) { request = false; } if (!request) { return; }
(The original file also tested for new ActiveXObject but I think that is no longer required.)
Somehow, despite being a javascript dummy, I managed to get the original file working. Can anyone give me a clue, please, on what is required to make the same type of script work in WordPress?
Thanks.
- The topic ‘Using javascript in WordPress’ is closed to new replies.