document.getElementById('ACOptions').innerHTML = "";
$.ajax({url: "SearchAvailableAircraft.php?ID=<?php echo $SimID; ?>&Code=<?php echo $SimCode; ?>&Search=" + S, success: function(result){
/alert(result);/
var MyAircraftList = result.AircraftList
This is my jquery script, it's calling a pho page which returns the below JSON object.

{"status":200,"status_message":"Valid Account","AircraftList":[{"ID":"1","FullTXT":"Boeing 777-200ER","TypeCode":"772","Manufacturer":"Boeing","Model":"777","Variant":"200ER","PaxCnt":"305","RangeNM":"5240","MinRwFT":"8000","Cost":"261500000","DeliveryDelay":"18"},{"ID":"2","FullTXT":"Airbus A320-200","TypeCode":"320","Manufacturer":"Airbus","Model":"A320","Variant":"200","PaxCnt":"186","RangeNM":"3300","MinRwFT":"2100","Cost":"98000000","DeliveryDelay":"9"}]}

How can I loop though the aircraft list options??

    Is this a JavaScript question? If so, I'll move it to the client-side forum.

    Here's the jsonlint.com formatting, if that helps anyone answer this:

    {
    	"status": 200,
    	"status_message": "Valid Account",
    	"AircraftList": [{
    		"ID": "1",
    		"FullTXT": "Boeing 777-200ER",
    		"TypeCode": "772",
    		"Manufacturer": "Boeing",
    		"Model": "777",
    		"Variant": "200ER",
    		"PaxCnt": "305",
    		"RangeNM": "5240",
    		"MinRwFT": "8000",
    		"Cost": "261500000",
    		"DeliveryDelay": "18"
    	}, {
    		"ID": "2",
    		"FullTXT": "Airbus A320-200",
    		"TypeCode": "320",
    		"Manufacturer": "Airbus",
    		"Model": "A320",
    		"Variant": "200",
    		"PaxCnt": "186",
    		"RangeNM": "3300",
    		"MinRwFT": "2100",
    		"Cost": "98000000",
    		"DeliveryDelay": "9"
    	}]
    }
    

      Use [man]json_decode/man to get the object in PHP.

      $ss= json_decode($string);
      
      foreach ($ss->AircraftList as $plane) {
      
      echo $plane->FullTXT . PHP_EOL;
      
      }
      Boeing 777-200ER
      Airbus A320-200

        Thanks, I think I want to do the response in JS but it's not working so still looking for a solution

          Write a Reply...