Q:

Want to upload and parse a json text and load it to my index page by a click of a button using ajax

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>

A:

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/

