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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T22:25:14+00:00 2026-06-09T22:25:14+00:00

With an array like mine below, how can I read the values of only

  • 0

With an array like mine below, how can I read the values of only the first line and the loop through the other from the second line onward? I’ve included comments in the code to give you an idea of what I’m trying to achieve.

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>PHP, jQuery search demo</title>
<link rel="stylesheet" type="text/css" href="my.css">
<script type="text/javascript" src="http://localhost/dev/ajax/jquery.js"></script>
<script type="text/javascript">
$(function() {

    $(".errCheck").click(function() {
             $.ajax({
                type: "GET",
                url:  "test_errors.php",
                dataType:"json",
                cache:false,

                success: function(data){
                //if 1st line of array: success == True How can I do this?
                //Redirect
                //else
                $('#errors div').empty();
                $.each(data, function (loc, msg) {//start from the second array value, in this case errOne
                $(loc).html(msg);
                });              

              },

            });    

        return false;
    });
});
</script>

</head>
<body>
<div id="container">
<div id="errors">
<div id="errOne"></div>
<div id="errTwo"></div>
<div id="errThree"></div>
</div> 
<input type="submit" class="errCheck" value="Check">
</div>
</body>
</html>

My test error messages file:

<?php

$errors['success'] = "false";
$errors['#errOne'] = "Enter a valid username";
$errors['#errTwo'] = "Enter a valid email";
$errors['#errThree'] = "Enter a valid password";

echo json_encode($errors);

?>
  • 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-09T22:25:16+00:00Added an answer on June 9, 2026 at 10:25 pm

    You can use shift() to return the first element in an array and remove it from the array

    var error = data.shift();

    So, var error will be your check and data can then be used in you $.each()

    @Joseph Silber – Congratulations on spotting my deliberate mistake above ;-P

    Use

    delete myObject.property; // or myObject[property]
    

    As per How do I remove a property from a JavaScript object?

    EDIT I guess this is now the same as another answer but I felt like I might as well write the code in…

    And use a proper boolean as stated elsewhere

    success: function(data) {
      if(data.success == false) {
        delete data.success;
        $.each(data,function(loc, msg){
          $(loc).html(msg);
        })
      } else {
        // passed validation code
      }
    }
    

    Although I’d prefer to arrange the Json like this

    {
      success: false,
      errors: [
        {fieldKey: 'string'},
        {fieldKey: 'string'}
      ]
    }
    

    Etc.

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

Sidebar

Related Questions

I have a 2D string array consisting of values like as { Home,0.1256784 Contact,-0.56789
I couldn't find a question that was quite like mine, but if you can
Just like in the title. I got one array of strings and second array
a array like this: a = [<root>, <products>, <product>, <id>, 1, </id>, <name>, name1,
I declare array like that private double[] array = new double[length] . Is it
I have a numpy array like this: x = np.array([[1,2,3],[4,5,6],[7,8,9]]) I need to create
I have defined an array like so : var myArray = {myNewArray: ['string1' ,
I have an array like this var array = [{ order: 3, sub -
I have an array like: errors = [ {...}, {...}, {...} ] It's an
I have an array like this one $state[1]='FG'; $state[2]='BU'; $state[3]='CA'; ... $state[150]='YT' What I

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.