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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:19:22+00:00 2026-05-25T17:19:22+00:00

I have a 2 part question. How do I get my script to alert

  • 0

I have a 2 part question.

  1. How do I get my script to alert the variable type in javascript
    instead of [object object]?
  2. How do I get my Json to successfully convert to an Array without returning
    NULL?

Javascript:

$(document).ready(function() {

// Arrays
var title = $('.table-item-1 > strong').map(function () {
    var value = $(this).text();
        return value;
    }).get();

var name = $('[width|="23%"]').next('.table-item-1').map(function () {
    var value = $(this).text();
        return value;
    }).get();

var phone = $('[width|="23%"]').next('.table-item-1').next('.table-item-1').map(function () {
    var value = $(this).text();
        return value;
    }).get();

var fax = $('[width|="23%"]').next('.table-item-1').next('.table-item-1').next('.table-item-1').map(function () {
    var value = $(this).text();
        return value;
    }).get();

var email = $('[width|="23%"]').next('.table-item-1').next('.table-item-1').next('.table-item-1').next('.table-item-1 , a').map(function () {
    var value = $(this).text();
        return value;
    }).get();

// Individual    
var brand = $('.panel-1 tr strong').html();
var corp = $('.panel-1 tr td :gt(0)').html();
var web = $('.panel-1 tr td ~ .focus :not(strong)').html();
var lna_code = $('.panel-1 tr td :last').html();
var lna_class = $('.panel-1 tr td :gt(4)').html();


var items = {
    'brand': brand,
    'corp': corp,
    'web': web,
    'lna_code': lna_code,
    'lna_class': lna_class,
    'title': title,
    'names': 
        name,
    'phones': 
        phone,
    'faxes': 
        fax,
    'emails': 
        email,
};

var data = $.toJSON(items);

$.ajax({
    type: 'POST',
    url: 'http://xxxxxx.com/xxxxx/PHP/excel.php',
    data: {'data':data},
    success: function(data) {
        alert('success');
    },
    complete: function(data){
        alert(data); // alerts [object object] , want a string
   }
});

});

PHP:

<?php
$json = $_POST['data'];
$result = json_decode($json);
$resultsType = gettype($result);
echo $resultsType;
?>

note: I’m using json.js for the $.toJSON(items); call

  • 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-25T17:19:23+00:00Added an answer on May 25, 2026 at 5:19 pm

    if you want the result to be an array on the PHP side, it should probably be an array on the javascript side:

    [value1]
    

    instead of

    {key1 = value1}
    

    what is happening in your code is you are instead creating an object. the object is probably what you actually want however as it does not seem like you have to iterate over the values on the PHP side, which would be the only reason for an actual array as opposed to an object.

    if you leave the code as is, you access the values on the PHP side like so:

    echo $result->brand;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a call to this php script (only part in question displayed) if
I have the following script element in my web page: <script src=default.js type=text/javascript></script> Using
I have a two part question Best-Practice I have an algorithm that performs some
Multiple part question on running gvim on windows xp. I have a _vimrc file
This is probably a multi-part question. Background: we have a native (c++) library that
Ok so part two of I have no will power experiment is: Summary Question
I ask this question in anticipation as part of a project. I have experience
I have a script to convert to base 62 (A-Za-z0-9) but how do I
In a PowerShell script, how does one get the value of an environment variable
I have a question regarding variable linking between objects. Because I'm learning Python programming

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.