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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:55:25+00:00 2026-05-27T05:55:25+00:00

I did not want to post this question since there are so many posts

  • 0

I did not want to post this question since there are so many posts already about JSON parsing in jQuery, but I cannot seem to get it work. I have this select list that is populated by this JavaScript code. This is called from the HTML page onload:

function populateclienteslist () {
$.post('php/listaclientes.php', function(data){
data = JSON.parse(data);     
    if (typeof (data) == 'object' && JSON.parse ){
var html = '';
var len = data.length;
for (var i = 0; i< len; i++) {      
    var d = data[i];
    if(!d.error){
    html += '<option value="' + (i+1) + '">' + d.cliente + '</option>';
}else{
    alert(d.error);
    }}
$('#clienteslist').append(html);}else{
    console.log("error");
    }
})
}

This works fine, and then when you select an item of the list the information of the list is displayed by this code, the function is called with the onchange;

function selectedcliente(){

var id_clientea = $('#clienteslist').val();
var jqxhr = $.post('php/selectcliente.php',{"id_cliente":id_clientea}, function(data){
data = JSON.parse(data)
if(typeof(data) == 'object' && JSON.parse){

var html = '';
var len = data.lenght;
for(var i = 0; i<len; i++){
var d = data[i];
    if(!d.error){
   html += d.contacto;
   d.contacto + '">'; 
    }else{
        document.write(data[i].error);  
        }

    }

    alert(html);
}else{
    alert("Is not object");

    }
    }
    )

}
  • 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-27T05:55:25+00:00Added an answer on May 27, 2026 at 5:55 am

    var len = data.lenght;

    should be

    var len = data.length;

    EDIT: Sorry, forgot to mention that edit needs to be done in selectedcliente()

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

Sidebar

Related Questions

I searched and found this question but did not like the answer. Is there
I'm not clear how to pose this question. If I did, I'd probably be
Searching did not find a similar question, so: How can POST data used by
I looked at this question: Uploading multiple files with Django but it did not
i searched a lot for an answer to this question but i did not
I have asked the same question before, but did not get what I want.
Lot of googling did not help me! Are there any good dictionary web based
I did search the forum and did not find a similar question. I'm looking
Just could not get this one and googling did not help much either.. First
Before answering this question, understand that I am not asking how to create 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.