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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:03:48+00:00 2026-06-04T08:03:48+00:00

I created a text called Name under my content folder. I wrote it in

  • 0

I created a text called Name under my content folder. I wrote it in Json format. I am trying to take that Name.text and display it after the result of clicking a button. I came up with some parsing code to parse the json. I just dont know where to put it at. I think it go in my success: function(data) area somewhere. Please help me out.

<p>
  <script type ="text/jscript">
      $(document).ready(function () {
          $.ajax({
              url: "/MvcApplication1/Content/Name.txt",
              success: function (data) {
                  var jsnObj=$parseJSON(data);
                  $("#button").click(function(){
                       $("p").append(jsonObj.First);
                       $("P".append(jsonObj.Last);

                   });

              },
              error: function () {
                  alert("error");
              }
          });
      });

  </script>
</p>
<div id="nameDiv"></div>
<button id ="button><Get Name</button>
  • 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-04T08:03:48+00:00Added an answer on June 4, 2026 at 8:03 am

    yes, create 2 functions, one that does the Ajax and one that does the parsing, you need to pass the “data” to the parse function .

      function doParse(jsondata) {
    
         var jsonobj = $.parseJSON(jsondata);
    
         /*  ... next stuff */
    
        /* UPDATE ( as comment ): say jsonobj  is {"pizzatype":"ham"} */
        /* output examples */
         alert(jsonobj.pizzatype);
         $("#mydivonthepage").html("My favourite pizza is"+jsonobj.pizzatype);
    
    
        }
    
         $(document).ready(function () {
          $.ajax({
              url: "/MvcApplication1/Content/Name.txt",
              success: function (data) {
                  doParse(data);
              },
              error: function () {
                  alert("error");
              }
          });
      });
    

    NB* you can simplfy further – see getJSON for examples –http://api.jquery.com/jQuery.getJSON/

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

Sidebar

Related Questions

I'm trying to display text that is input by the user if it is
I created a graphic in Flash CS4 that contains text. I embedded the appropriate
I've created a form that stores free text fields into a MySQL database. All
I am trying to take a block of text and scan it for specific
I created a table view and display some text there with help of experts
So I've created a small custom dialog application for sitecore that is called through
Basically, I've an object: function tomatoe(name, owner) { $('<div>').click(this.squish).appendTo(myElement).text('I\'m a happy tomatoe called '
I've created a text field using storyboard and am trying to setup the delegates.
I created my own file type called foo. It is text file. What I
I have created a page called profile.php that gets a value from mainpage.php, by

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.