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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:01:39+00:00 2026-06-11T12:01:39+00:00

I’m new to jquery and just started reading up on json early last night.

  • 0

I’m new to jquery and just started reading up on json early last night. I have a working ajax call that passes simple data to a php script, works on the data and returns a single value. Works great.

I want to add the passing of arrays and non array data back and forth and after reading piles of articles saying json IS the way to go!!!! BUT… also that json isn’t secure, … put braces, dont put braces – use json decode, dont use it, make sure the top item is an object, some say put a “d” at the top, some use serialization, some don’t use it. Do I have to put the curley braces around the data? Or does Jquery. Some people have said to also add a header that specifies application/json or some other header… and others have said it breaks IE7… some have said to add …

"dataType" : json

in the ajax call. Do you see why I am confused now?

… and … In the PHP do I have to also use rawurldecode? before json decode since my ajax urlencodes the data … it’s sooo confusing…

I don’t want this to be a bigger security hole than it already is… I would like to do it PROPERLY and to SPEC. if there is a spec.

Most people thankfully say… it’s about HOW you use it (jquery, JSON) etc and THAT makes it “secure”. And by secure… I mean, used properly. Nothing on the client side is EVER secure.

What I’m stuck on is simple I’m sure but after reading for over 9+ hours I can’t find a definitive answer. Why can’t the people who make the languages (Jquery) write an example that says… here’s the PROPER way to do it now that we have included json support!?!

And yes, I’m being a tad wordy in this top portion because I’ve asked short questions before and been downvoted and criticized and accused of not researching things or not “looking into it enough” when I NEVER ask a question here without at least 5+ hours of intense reading, scanning websites, etc.. and usually I only come here after way over 9+ hours …

…but the information I have found is broken, old, and in too many pieces and I want to do it PERFECTLY!!! 🙂 The best website I found so far was for pulling in flicker pictures but it didn’t show how to send properly so I left there happy to find the article… but didn’t know how to apply it to MY situation…

Please see the comments in my code for the tips I need please or even better – fix up my code so I can send those 2 datas back and forth and in each language can you assign a value to a tmp variable so I can SEE how you extract the information from the passed data? Thanks…

JQUERY/JS (my old code) (code snippits)

    //Here's some sample data... - HOW DO I SEND THIS AS JSON (please) back and forth?
    var myarray = new Array();
    myarray.push("One");
    myarray.push("Two");
    myarray.push("Three");
    var someOtherData = "helpmeplease";

    $.ajax({
        url: "../../ajax/ajax.php",
        type: 'POST',
        data: ({
            "testarray" : myarray,
            "somemoredata" : someOtherData
        }),
        success: function(results) {
            // what do I do with results?  please alert the 2 passed variables back from php
            // for example alert("Test:" . results[0] . results.someOtherData) or however you
            // access the returned values...

PHP RECEIVE FROM AJAX (my old test code)

     $test1 = rawurldecode($_POST["somemoredata"]);
     $test2 = rawurldecode($_POST["testarray"]);
     $test3 = testarray[0]; // should be One

PHP RETURN

     // please send any data back to the Ajax call 1 array, 1 normal data please and alert
     // the data please so I can see how it's pulled back out...
     return $data; // 1 array, 1 normal variable please

More info on my stuff…

  • my website is UTF-8 encoded

  • My data set will be under 4 megs. Most likely under 200k.

  • No cross domain stuff taking place

  • I have a nonce, per page token authentication system that works great

  • what can go in the data? ANYTHING? Any symbols, or stuff that should NOT be included that would break the JSON code or the passing of data back and forth?

  • any other tips, suggestions, warnings?

Thank you for your time.

  • 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-11T12:01:40+00:00Added an answer on June 11, 2026 at 12:01 pm

    There is no need to send data as JSON, it would mean to include other libraries for nothing. You can use jQuery to send data as array, and read it as array in your PHP script.

    Eg:

    1. Returning a single var from PHP:

      <script type="text/javascript">
      $(window).load(function(){
          var myarray = new Array();
          myarray.push("One");
          myarray.push("Two");
          myarray.push("Three");
          var someOtherData = "helpmeplease";
      
          $.ajax({
              url: "../../ajax/ajax.php",
              type: 'POST',
              data: ({
                  "testarray" : myarray,
                  "somemoredata" : someOtherData
              }),
              success: function(results) {
                  alert(results);
              }
          });
      });
      </script>
      

      and your script:

      <?php
          $testarray = $_POST['testarray'];
          echo $testarray[0]; // prints One
          $someOtherData = $_POST['someOtherData']; // prints helpmeplease
      ?>
      
    2. Returning the data to jQuery as array and other single variables.

      You add dataType: "json" and return data as JSON:

      <script type="text/javascript">
      $(window).load(function(){
          var myarray = new Array();
          myarray.push("One");
          myarray.push("Two");
          myarray.push("Three");
          var someOtherData = "helpmeplease";
      
          $.ajax({
              url: "../../ajax/ajax.php",
              type: 'POST',
              dataType: 'json',
              data: ({
                  "testarray" : myarray,
                  "somemoredata" : someOtherData
              }),
              success: function(results) {
                  alert(results.somemoredata); // will alert 'helpmeplease'
                  alert(results.testarray[1]); // will alert 'Two'
              }
          });
      });
      </script>
      

      and script:

      <?php
          // I used the same POST fields, but it can be any other data
          $array = array();
          $array = $_POST['somemoredata'];
          $array = $_POST['testarray'];
          echo json_encode($array); 
      ?>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) 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.