html5 ajax jquery

I have below codes and it was working fine. I just want to put the value inside of select html.

Thanks

    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>	    
    <script type="text/javascript">
        function GetModelList() {
            var customerNo = "315217";            
            var GetModelListJSon = "http://clientaccesstest.abc.com/wcf/orders/RestService/ProService/GetModelListJSon";
            $(document).ready(function () {
                $.ajax({
                    crossDomain: true,
                    cache: false,
                    type: "GET",
                    async: false,
                    dataType: "json",
                    contentType: 'text/plain',
                    url: GetModelListJSon + encodeURIComponent("(066,315217)"),
                    success: function (data) {
                        $('#data').html(data);
                        if (data == null)
                        return;
                        resultObj = jQuery.parseJSON(data);
                        alert(resultObj.Data);
                    },
                    error: function (xhr, status, error) {
                        $('#data').html(xhr.responseText);
                        alert(xhr.responseText + " : error GetModelListJSon");
                        alert(status);
                        alert(error);
                    }
                });
            });
        }
    </script>
     <body onload="GetModelList()">
       <form action="" id="test" name="test">
         <select id="modelList" name="modelList"></select>
       </form>
     </body>

Open in new window


My question is how can I code and make the below string inside of <select></select> like I want to make it below
<select>
<option value="ModelNo">Mode No + Net Price</option>
</select>

Open in new window

?

Thanks

alert message sample below:
{"PackageKey":null,"PackageNo":1,"TotalPackages":1,"Status":"Ok","Data":"[{\"ModelNo\":\"DISCOUNT\",\"ModelName\":\"Instant Rebate \",\"NetPrice\":0.0,\"ListPrice\":0.0,\"AMD\":0.0},{\"ModelNo\":\"DISCOUNT1\",\"ModelName\":\"INSTANT REBATE ON DISPLAYS \",\"NetPrice\":0.0,\"ListPrice\":0.0,\"AMD\":0.0},{\"ModelNo\":\"DISCOUNT2\",\"ModelName\":\"INSTANT REBATE GYHM600 REBATE ONLY VALID ON ORDERS RECEIVED BY 12/31/14 \",\"NetPrice\":0.0,\"ListPrice\":0.0,\"AMD\":0.0}

Open in new window

LVL 1
ITsolutionWizardAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
is it possible that you add an ID attribute to your select element?
In the below sample I expect that the select has an id of "id=IDofSelect".

I do not fully understand the JSON response, as it has also a data element inside - but from your post it should work like this:
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>          
<script type="text/javascript">
	function GetModelList() {
		var customerNo = "315217";            
		var GetModelListJSon = "http://clientaccesstest.abc.com/wcf/orders/RestService/ProService/GetModelListJSon";
		$(document).ready(function () {
			$.ajax({
				crossDomain: true,
				cache: false,
				type: "GET",
				async: false,
				dataType: "json",
				contentType: 'text/plain',
				url: GetModelListJSon + encodeURIComponent("(066,315217)"),
				success: function (data) {
					$('#data').html(data);
					if (data == null)
					return;
					resultObj = jQuery.parseJSON(data);
					//alert(resultObj.Data);
					var nestedData = jQuery.parseJSON(resultObj.Data.Data);
					$.each( nestedData, function(i, item) {
						$("#IDofSelect").append("<option value='" + item.ModelNo + "'>" + item.ModelNo + " " + item.NetPrice + "</option>");
					});​
				},
				error: function (xhr, status, error) {
					$('#data').html(xhr.responseText);
					alert(xhr.responseText + " : error GetModelListJSon");
					alert(status);
					alert(error);
				}
			});
		});
	}
</script>

Open in new window


HTH
Rainer

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ITsolutionWizardAuthor Commented:
See attached. Invalid / illegal character occurred.
testing3.jpg
ITsolutionWizardAuthor Commented:
I fixed it by modified below

Take out ";" and remove .Data

var nestedData = jQuery.parseJSON(resultObj.Data);
                              $.each( nestedData, function(i, item) {
                                    $("#IDofSelect").append("<option value='" + item.ModelNo + "'>" + item.ModelNo + " " + item.NetPrice + "</option>");
                              });
ITsolutionWizardAuthor Commented:
I posted another related question.  If you have time, please helps.

http://www.experts-exchange.com/Programming/Languages/.NET/Web_Services/Q_28651592.html
ITsolutionWizardAuthor Commented:
great helper
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.