• I’ve written a script with AJAX that calls on a php file to fetch content from a database and present it inside a div when a form button is pressed. The script is entirely javascript and HTML.

    I have tested the script, and it works perfectly well in its own right.

    I would like to create a wordpress page that runs this script.

    I have pasted the ajax script into the page editor (using the HTML view) and saved the draft. When I preview the page, the script does not fetch the data and/or change the content of the div when the button is pressed.

    I don’t understand why this should be, and so I’m posting to ask if anybody here can explain why and possibly offer a solution.

    Many thanks.

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you are using jQuery for ajax, then you should also include jQuery javascript files.

    Thread Starter krissie

    (@krissie)

    Thank you for that.

    I’m actually using plain javascript, so no Jquery needed.

    I’ve a new problem now though.

    I’ve got it working (the problem was that the editor saved a paragraph tag in the code)… and that’s great. However, when I publish the page it stops working. It seems that the paths to the files change somehow when it’s published – does anyone know how?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add ajax content to page?’ is closed to new replies.