Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8963065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:16:40+00:00 2026-06-15T16:16:40+00:00

I am developing custom theme for WP and I have a problem with ajax

  • 0

I am developing custom theme for WP and I have a problem with ajax callbacks…
This is my header:

<script>    
//alert("Data Loaded");
    $('#domaincheck').submit(function(){
        alert("Button pressed");
        $.post('<?php bloginfo('template_directory'); ?>/check.php', $(this).serialize(), function(data){
        alert("Data Loaded: " + data);
        });             
        return false;
    });
</script>

In my theme file i have simple form like:

<form id="domaincheck">
Name: <input type="text" name="urname">
Birthplace: <input type="text" name="urbirth">
<input type="submit" name="submit" value="Submit">
</form>

Now when I click submit button – pages just reloads 🙁 when I move this out of WordPress everything is working properly. Is there a way to make this to work in WordPress ? Also another strange thing is when I wrap JS code in “document ready” – javascript is not working at all…. without documentready it displays the Alert – but not the callback – it just reloads page… Once again – outside of wordpress template it works like it should.

Thanks, Peter

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:16:41+00:00Added an answer on June 15, 2026 at 4:16 pm

    I have done on my Localhost and this is doing a ajax call very fine:

    i added one main jquery plugin reference in header.php file at <head>

    <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js'></script>
    <script type='text/javascript'>
       $(function(){
           $('#domaincheck').submit(function(e){
               e.preventDefault();
               alert("Button pressed");
               $.post('<?php bloginfo('template_directory'); ?>/check.php',$(this).serialize(), function(data){
                   alert("Data Loaded: " + data);
               });
           });
       });
    </script>
    

    and this one is the check.php file php code:

    <?php
        if((isset($_POST['urname'])) && (isset($_POST['urbirth']))){
            echo $_POST['urname'];
            echo $_POST['urbirth'];
        }
    ?>
    

    and i got the alert of the posted data.

    try this and see if this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently developing a custom WordPress theme and ran into a problem. I
I enjoy developing algorithms using the STL, however, I have this recurring problem where
I'm developing a custom WordPress theme for a company, and I'd like to keep
I'm developing a custom wordpress blog theme. Does anyone know if there is a
I'm developing a custom search control and setting its configuration based on this sample
I am developing a custom list-search tool. I have multiple custom properties to retain
I'm developing a custom theme, based on PageBuilder2 (csa2.theme) for WebSphere Portal 7. I'm
I am developing an android application in which i have to implement custom rating
I'm developing a custom datatype with the usercontrolwrapper in umbraco. I have some dataeditorsettings
H guys. I'm developing a custom component for SSIS. I'm having a problem when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.