Forums

add ajax content to page? (3 posts)

  1. Krissie
    Member
    Posted 1 year ago #

    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.

  2. Reuben Gunday
    Member
    Posted 1 year ago #

    If you are using jQuery for ajax, then you should also include jQuery javascript files.

  3. Krissie
    Member
    Posted 1 year ago #

    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?

Topic Closed

This topic has been closed to new replies.

About this Topic