Jump to content

How to ajax to insert data in table

Recommended Posts

Hello everyone,

i am using the following code ajax code to insert in table but unable to get the result

            url: 'subcriberList.php',
            data: {'email' : email,'name' : name},
            type: 'post',
            success: function(success) 
                  title: "Thank you for subscribing!",
                  icon: "success",

Link to comment
Share on other sites

Hi, welcome to the forums!

Are you using ProcessWire for this? It looks like you’re submitting your data to a file called “subcriberList.php”. Can you elaborate on where this file is and what it does?

Link to comment
Share on other sites

Yes i am using ProcessWire. Basically file called “subcriberList.php” contains an  insert query like write in corePHP to insert a record in database table.

 And 'subcriberList.php' is present in the template folder.

Link to comment
Share on other sites

By default, ProcessWire will prevent you from running subcruberList.php like that (you will get error 404 or 403).

What you can do is create a ProcessWire template and set subcriberList.php as its template file. Then create a page with that template and do your POST request to that page.

There are a couple of threads in the forums about handling forms that may be of help. Also consider using a form module such as FormBuilder.

  • Like 3
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...