Solved

how to make an ajax call return and parse JSON

Posted on 2014-07-31
2
214 Views
Last Modified: 2014-08-14
Hi..
I have page that returns JSON.

webservice.asp?type='Json'&id=123

Json Looks like this..


[{"ID":805,"TitleId":"1519","UserId":"XXX","Comments":"passed final qa","CommentDate":"3/18/2013 3:26:06 PM","Type":"Public","error_code":null,"Issue":"N","IssueClosed":"N","UpdatedDate":"3/18/2013 3:26:06 PM","UpdatedBy":"XXX"}]


How can I make a ajax call using JQuery  return the JSON and parse it so I place the ID value in the ID field on a form?  What's the syntax
0
Comment
Question by:JElster
2 Comments
 
LVL 15

Accepted Solution

by:
Insoftservice earned 250 total points
ID: 40232489
$.ajax({
                    type: "POST",
                    url: Host+'/webservice.asp',
                    data: "ms="+rand+"&type="+json"&id=123",
                    success: function(originalRequest){

                      var response = originalRequest;
                      alert(response)
ar json = $.parseJSON(response);
                        $('#results').html('Plugin name: ' + json.ID+ '<br />Author: ' + json.Titleid);


                    }
                  });
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 250 total points
ID: 40232606
$.getJSON( "webservice.asp?type=Json&id=123", function( data ) {
	$.each(data, function(i, field){
		$("#someinput").val(field.ID);
	});
});

Open in new window

0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question