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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T21:43:27+00:00 2026-05-17T21:43:27+00:00

Here is my code. You have to kindly look does it suffer from ‘same

  • 0

Here is my code. You have to kindly look does it suffer from ‘same origin policy’ in this shape. The domain for HTML is (http://127.0.0.1/jqload.html) & php file (http://127.0.0.1/conn_sql.php). This is json format : [{“options”:”smart_exp”},{“options”:”user_int”},{“options”:”blahblah”}]
I actually want to append json data that I receive in HTYML with user input & I am suffering in that. If I use eval for parsing, it works fine to point its put here. But if I use JSON.parse to parse, the whole code stops working & this error message is issued ‘”IMPORTANT: Remove this line from json2.js before deployment”. I put my code for some other question on stackoverflow forum & I was told that my code suffer from ‘same origin policy’ that causes the problems in appending JSON data. So can you kindly see does my code suffer from this policy? Though I have doubts it suffers from that policy as I learn that it restricts if files reside on different domains, here both files reside next to each other.

Code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
 "http://www.w3.org/TR/html4/strict.dtd">
<html><head></head>
 <body> 
  <form name="index">
   <p><input type = "text" id = "txt" name = "txt"></input>
   <p><input type = "button" id = "send" name = "send" value = "send" onClick= 
       "ADDLISTITEM"></input>
   <p><select name="user_spec" id="user_spec" />
  </form>
  <script>
  function ADDLISTITEM()
  {
      alert (json.length); // working
      alert json.options[1]; // do not show any value, message just for testing
      json.options[json.length+1] = 'newOption'; //not working; HELP HERE
      jsonString = JSON.stringify(json);//working fine for current data
      alert(jsonString);
      //here I have to implement send this stringify(json) back to server,HELP  
      //HERE     
  }                    
  </script>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  <script>
  var json;
  $(document).ready(function() { 
      jQuery .getJSON("http://127.0.0.1/conn_mysql.php", function (jsonData) {
          json = jsonData;
          $.each(jsonData, function (i, j) {
              document.index.user_spec.options[i] = new Option(j.options);
          });
      });
  });
  </script>
 </body>
</html>
  • 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-17T21:43:28+00:00Added an answer on May 17, 2026 at 9:43 pm

    You’re on the right track, but here: $.each(jsonData, function (i, j) { ... } you are actually looping through each character of the jsonData string, and not the json object. Just change jsonData to json inside the $.each(), and it should work fine (regardless of whether you’re using eval or JSON.parse, but I recommend the latter).

    Edited: Since you are using jQuery.getJSON(), you don’t need to use eval or JSON.parse – jQuery does it for you. So inside your callback function, just set json = jsonData .

    <script>
      var json;
      $(document).ready(function() { 
          jQuery .getJSON("http://127.0.0.1/conn_mysql.php", function (jsonData) {
            json = jsonData;
            $.each(json, function (i, j) {
                document.index.user_spec.options[i] = new Option(j.options);
            });
          });
      });
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question on xquery grouping. From what I understand, the usual case
I have to return data fetched from MySQL table into a php file as
Kindly provide me a sample code which will contain the following: ListView in which
I'm attending the course of IOS development on itunesU (from Stanford University). And i
I am building a code which displays user information on search. User information, is
I am trying to implement a custom menu for Internet Explorer 7.0. For this
I am trying to write a simple state machine executor in C. I have
this should be a simple question, but the answer has eluded me for some
Problem I am making ajax call to server1 i.e. csce and once I got

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.