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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T22:09:41+00:00 2026-05-18T22:09:41+00:00

First off sorry if I’m missing something simple just started working with AJAX today.

  • 0

First off sorry if I’m missing something simple just started working with AJAX today. I have an issue where I’m trying to get information from my database, but different records have different amounts of values. For instance, each record has a “features” column. In the features column I store a string. (ex: Feature1~Feature2~Feature3~Feature4… ) When I’m building the object I take apart the string and store all the features into an array. Some objects can have 1 feature others can have up to whatever. So… how do I return this values back to my ajax function from my php page? Below is my ajax function that I was trying and I’ll provide a link with my php file. [ next.php : http://pastebin.com/SY74jV7X ]

$("a#next").click(function()
{
    $.ajax({
           type : 'POST',
           url  : 'next.php',
           dataType : 'json',
           data     : { nextID : $("a#next").attr("rel") },
           success  : function ( data ) {

                      var lastID = $("a#next").attr("rel");
                      var originID = $("a#next").attr("rev");

                      if(lastID == 1)
                      {
                        lastID = originID;  
                      }
                      else
                      {
                        lastID--;
                      }


                      $("img#spotlight").attr("src",data.spotlightimage);
                      $("div#showcase h1").text(data.title);
                      $("div#showcase h2").text(data.subtitle);
                      $("div#showcase p").text(data.description);
                      $("a#next").attr("rel", lastID);


                      for(var i=0; i < data.size; i++)
                      {
                          $("ul#features").append("<li>").text(data.feature+i).append("</li>");
                      }

                      /*
                      for(var j=1; j < data.picsize; j++)
                      {
                          $("div.thumbnails ul").append("<li>").text(data.image+j).append("</li>");
                      }
                      */                          
           },
           error    : function ( XMLHttpRequest, textStatus, errorThrown) {
                     $("div#showcase h1").text("An error has occured: " + errorThrown);
           }
    });
});
  • 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-18T22:09:41+00:00Added an answer on May 18, 2026 at 10:09 pm

    First replace the below in your next.php file:

    for ( $i=0; $i < $arraySize; $i++ )
    {
        $return['feature'.$i.''] = $features[0];
    }
    

    With:

    $return['features'] = $features;
    

    P.S: the current code is wrong you should have ... = $features[$i]; anyway, you don’t need that just send the array as is. and then in the JS part replace:

    for(var i=0; i < data.size; i++)
    {
        $("ul#features").append("<li>").text(data.feature+i).append("</li>");
    }
    

    With:

    $.each(data.features, function(k,v){
        var li = '<li>' + v + '</li>';
        $("ul#features").append(li);
    });
    

    This way, don’t need the data.size anymore.

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

Sidebar

Related Questions

First off, sorry if the title is confusing! I'm working on a part of
First off, I am using Windows XP. I have multiple hard drives and it
First off, there's a bit of background to this issue available on my blog:
First off, I'm working on an app that's written such that some of your
Hey guys, first off all sorry, i can't login using my yahoo provider. anyways
First off, sorry for the lame title, but I couldn't think of a better
First off, sorry for the title, it was hard to come up with a
First off, I'm sorry if the title doesn't explain this very well. I'm looking
Sorry this is my first time trying to create a plugin, so I might
First off, I understand the reasons why an interface or abstract class (in the

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.