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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:58:12+00:00 2026-06-12T01:58:12+00:00

Why I am getting typeError value is null but In my firebug I can

  • 0

Why I am getting typeError value is null but In my firebug I can that there is the values and not null, Whats the problem?

Here’s my ajax code:

    $.ajax({
    url: 'get-products.php',
    type: 'post',
    datatype: 'json',
    data: { category: $('.category').val().trim(), keyword: $('.keyword').val().trim() },
    success: function(data){
        var toAppend = '';
        toAppend += '<thead><th>Product Name</th><th>Image</th><th>Price</th><th>Weight</th><th>ASIN</th><th>Category</th></thead>';
        if(typeof data === "object"){
            for(var i=0;i<data.length;i++){
                toAppend += '<tr><td>'+
                data[i]['product_name'][0]+'</td><td><img src="'+
                data[i]['image'][0]+'" alt=""></td><td>'+
                data[i]['price'][0]+'</td><td>'+                            
                data[i]['weight']+'</td><td>'+                                      
                data[i]['asin'][0]+'</td><td>'+                                         
                data[i]['category'][0]+'</td></tr>';
            }
            $('.data-results').append(toAppend);
        }
    }
});

Here’s my php code I know this is working:

    foreach($xml->Items->Item as $item){
$items_from_amazon[] = array(
        'asin'=>$item->ASIN,
        'product_name'=>$item->ItemAttributes->Title, 
        'image'=>$item->SmallImage->URL,
        'price'=>$item->ItemAttributes->ListPrice->FormattedPrice, 
        'category'=>$item->ItemAttributes->ProductGroup, 
        'weight' => (string) $item->ItemAttributes->PackageDimensions->Weight.' lbs');
}
echo json_encode($items_from_amazon);
?>

Here’s the result from my firebug:

enter image description here

Here’s my sample ouput, can I still display the result even do there is still null result like in image if the image is null then there is no image displayed

enter image description here

  • 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-12T01:58:13+00:00Added an answer on June 12, 2026 at 1:58 am

    In the firebug image it looks like it says image is null at the 7th index.
    So if you do data.image[index] You are accessing a memory location that is invalid. The image property must point to something.

                 for(var i=0;i<data.length;i++){
    //You can save default image in a global variable, hidden div... it is up to you. 
                    var img ;
                    if(data[i]['image'] === null){
                      img = defaultImage ;
                    }
                    else
                    { 
                        img = data[i]['image'][0];  
                    }
                    toAppend += '<tr><td>'+
                    data[i]['product_name'][0]+'</td><td><img src="'+
                    img +'" alt=""></td><td>'+ //use img here
                    data[i]['price'][0]+'</td><td>'+                            
                    data[i]['weight']+'</td><td>'+                                      
                    data[i]['asin'][0]+'</td><td>'+                                         
                    data[i]['category'][0]+'</td></tr>';
                }
    

    You hopefully get the idea.

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

Sidebar

Related Questions

I'm trying to use defmacro in ClojureScript, but I'm getting a console error: TypeError:
i'm getting the following error: TypeError: document.getElementById(myTable) is null on document.write(document.getElementById(myTable).rows[i].innerHTML); It goes into
I have a problem in getting the datetime.date() value in my django... when i
Here is my problem - I'm trying to write a self-updating application, but I
Is there any idiom for getting an arbitrary key, value pair from a dictionary
In an ajax call (for a game) that tries to pass two values in
I'm getting TypeError: coercing to Unicode: need string or buffer, int found This is
I am creating a Word class and I am getting an error: TypeError: superclass
I'm getting the error: Uncaught TypeError: Cannot read property 'constructor' of undefined When declaring
I'm getting this error: uncaught TypeError: Object [object Object] has no method 'on' at

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.