#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2014
    Posts
    103
    Rep Power
    3

    Concatenate data in Ajax


    I'm trying to add additional parameters to my main data object in Ajax.

    I'm trying to add data1 to my data:data in Ajax

    How can I do this?

    Thanks



    Code:
    var data1 = {
    		maxStarRating:2
    	}
    	
    	var data = {
    		destinationString: destination,
    		arrivalDate: arrive,
    		departureDate: depart,
    		RoomGroup: {
    		  Room: { 
    					"numberOfAdults": numberOfAdults, 
    					"numberOfChildren": numberOfChildren 
    				}
    		},
    		numberOfResults: "3",
    		apiExperience: 'PARTNER_WEBSITE',
    	}
    	
    	//Ajax call and response
    	$.ajax({
    	  type:'POST',
    	  dataType: 'jsonp',
    	  url: 'http://dev.api.ean.com/ean-services/rs/hotel/v3/list?'
    	  +'cid=397896'
    	  +'&apikey=2bzg9qyxm687rsh5tthxtamf'
    	  +'&minorRev=99'
    	  +'&type=json&locale=en_US'
    	  +'&currencyCode=AUD',  
    	  data: data,
    	  beforeSend: function(){
    	   },
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,288
    Rep Power
    187
    Looks like your just sending the "data" variable, which is an object. You need to access the object by its keys and to access all the keys within the object; you would need to loop through the object.

IMN logo majestic logo threadwatch logo seochat tools logo