Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax complete function issue
    primarykey
    data
    text
    <p>I'm working on my collage project (Web app written in C#) and I'm using javascript to dynamically add hotels with details and image using following code:</p> <pre><code>$.ajax({ type: 'POST', url: 'WebServiceBooking.asmx/Hotels', data: "{'stars':'" + stars + "','countryid':'" + country + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { $('.hotels').empty(); var hotels = data.d; //getting List&lt;Hotel&gt; from [WebMethod](works) window.t = ""; window.ImageID = ""; $.each(hotels, function (index, hotel) { $.ajax({ //this ajax is getting Image for specified hotel.HotelID type: 'POST', url: 'WebServiceBooking.asmx/HotelImage', data: "{'hotelid':'" + hotel.HotelID + "'}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { window.ImageID = data.d; //$('.hotels-image').attr('src', 'ImageHandlerFromID.ashx?ImageID=' + data.d); }, complete: function (xhr, status) { window.t += "&lt;div class='hotel clearfix'&gt;&lt;h3&gt;&lt;a href='hotel.aspx?HotelID=" + hotel.HotelID + "'&gt;" + hotel.HotelName + "&lt;/a&gt;&lt;/h3&gt;&lt;p class='hotelAddress'&gt;" + hotel.HotelAddress + "&lt;/p&gt;&lt;p class='hotelPhone'&gt;" + hotel.HotelPhone + "&lt;/p&gt;"; window.t += "&lt;img class='hotels-image' src='ImageHandlerFromID.ashx?ImageID=" + window.ImageID + "'/&gt;"; window.t += "&lt;/div&gt;"; console.log(window.ImageID); } }); console.log(ImageID); }); console.log(window.t); }, complete: function (xhr, status) { $('.hotels').append(window.t); } }); </code></pre> <p>After several attempts, neither complete function works.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload