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

  • Home
  • SEARCH
  • 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 8578199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:19:56+00:00 2026-06-11T20:19:56+00:00

on form submit i am making an AJAX request to PHP code, in response

  • 0

on form submit i am making an AJAX request to PHP code, in response this is what i get.

var data = {
    "empty":{
        "game_sais_no":"Season cannot contain empty value",
        "game_sc_no":"Category cannot contain empty value",
        "game_st_no2":"Visiting team connot contain empty value",
        "game_room_no_2":"Visiting room cannot contain empty value",
        "game_room_no_1":"Local chamber cannot contain empty value",
        "game_date":"Game date should be specified",
        "game_time":"Game time should be specified",
        "game_time_start":"Game start time should be specified",
        "game_time_close":"Game close time should be specified",
        "game_place_no":"Arena \/ Lot should be specified",
        "game_status":"Game status should be specified"
    }
} 

1. i want to access single value. i tried accessing it like this.

data.empty.game_sais_no it returns me the value of undefined.

2. i want to loop through the json object and display all the messages back to the user. i tried using

$.each(data, function(index, value)(){
     //build the markup.
});

this is giving me unexpected result. where am i going wrong?

UPDATE :
i am not sure but for some reason it is giving me weird result, let me show you what exactly i am doing.

here is my ajax call to php.

$('#gce_game_btn').on('click', function(){
    var formData = $('#gce_game_form').serialize();
    $.ajax({
        type    : 'POST',
        url     : 'accueil.php?m=ajax&game=1',
        data    : formData,
        success : function(data) {
            //
        }
    });
});

here is the array which i am trying to send back.

Array
(
    [empty] => Array
        (
            [game_sais_no] => Season cannot contain empty value
            [game_sc_no] => Category cannot contain empty value
            [game_st_no2] => Visiting team connot contain empty value
            [game_room_no_2] => Visiting room cannot contain empty value
            [game_room_no_1] => Local chamber cannot contain empty value
            [game_date] => Game date should be specified
            [game_time] => Game time should be specified
            [game_time_start] => Game start time should be specified
            [game_time_close] => Game close time should be specified
            [game_place_no] => Arena / Lot should be specified
            [game_status] => Game status should be specified
        )

)

i am using json_encode() and echoing it back. which in turn gives me this as string.

{
    "empty":{
        "game_sais_no":"Season cannot contain empty value",
        "game_sc_no":"Category cannot contain empty value",
        "game_st_no2":"Visiting team connot contain empty value",
        "game_room_no_2":"Visiting room cannot contain empty value",
        "game_room_no_1":"Local chamber cannot contain empty value",
        "game_date":"Game date should be specified",
        "game_time":"Game time should be specified",
        "game_time_start":"Game start time should be specified",
        "game_time_close":"Game close time should be specified",
        "game_place_no":"Arena \/ Lot should be specified",
        "game_status":"Game status should be specified"
    }
} 
  • 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-11T20:19:57+00:00Added an answer on June 11, 2026 at 8:19 pm

    It works fine. Check the demo.

    $.each(data, function(index, value){
        console.log(index);
        $.each(value, function(index, value) {
           console.log(index, value);
        });
    });
    ​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am making a jQuery Ajax form submit to a PHP page that I
I've been making this login form in C# and I wanted to 'submit' all
Look at this: $('form).submit(function (event) { $(':input.required').trigger('blur'); var num = $('.warning', this).length; alert(num);//Focus here!
I have this form submit code: Event.observe(window, 'load', init, false); function init() { Event.observe('addressForm',
I'm following this tutorial about making an Ajax request on Rails: http://net.tutsplus.com/tutorials/javascript-ajax/using-unobtrusive-javascript-and-ajax-with-rails-3/ made _form
I'm making a form submit with jQuery's AJAX. I'm having several form's using AJAX
I am making an Ajax POST Request and it does not get recognized in
$('form').submit(function(){ this.action=http://www.sitename.com/post; return false; }); having altered the action attribute of the form ,i
$('#post_form').submit(function() { $(#ajax_bar_loader).show(); $.ajax({ url: 'add.html', data: $('#post_form').serialize(), dataType: 'json', type: 'post', success: function(
Javascript needed to prevent form submit if any of field is empty. all my

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.