Solved

how to make an ajax call return and parse JSON

Posted on 2014-07-31
2
199 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
Comment Utility
$.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
Comment Utility
$.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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article discusses how to create an extensible mechanism for linked drop downs.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now