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 6358713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:25:25+00:00 2026-05-24T23:25:25+00:00

I am building a small ajax contact form and i am testing it with

  • 0

I am building a small ajax contact form and i am testing it with a basic php file(learning the whole jQuery ajax thing), but for some reason it doesn’t works.

Even if the data is correct it stil gives me the error code(if data = ok doent work).

here’s the basic jquery code

$(document).ready(function ($) {

    $("#contactform").submit(function(){

        var str = $(this).serialize();

        $.ajax({
            type: obj.attr('method'),
            url: obj.attr('action'),
            data: str,
            dataType: 'html',
            success: function(data){  

                $('.acf-wrap').ajaxComplete(function(event, request, settings){  

                    if(data == 'OK'){
                        msg = 'success';
                    }else{
                        msg = data;

                    }

                    //display msg
                    $(this).html(msg);

                });

            }       
        });
        return false; 
    });
});

test php file

if(1 == 1){
    echo 'OK';
}else{
    echo 'error!!!';
}
  • 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-05-24T23:25:26+00:00Added an answer on May 24, 2026 at 11:25 pm

    The data is probably a JSON string. JSON.parse the data and access the “d” property…

    var parsed = JSON.parse(data);
    if(parsed.d == 'OK'){
        alert('works');
    }
    

    Actually wrote this answer on my phone… Might not be right. Couldn’t test it… 🙂

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

Sidebar

Related Questions

I'm building a small web app in PHP that stores some information in a
I am building a small dropdown menu with jQuery, but i am have a
I am building a poker game via html/php/ajax (and some other stuff) NO-FLASH .
I am building a small website for fun/learning using a fairly standard Web/Service/Data Access
I'm building a small app that calculate hash from any given file to multiple
I'm building a very small web ERP application with PHP / mySQL / CodeIgniter
Im building a small form using ComboBoxes with lots of items, and it seems
I'm building a small messaging system like you have in facebook. Only thing is
I 'am building a small windows form application. I have a View - a
First, I only have experience building small-medium sized websites with php so forgive me

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.