locked
Async httppost not working RRS feed

  • Question

  • User861911889 posted

    Hi,

    My problem is very unique. Its better to post my code so that you can understand.

    for(i = 0; i<arrTestIds.length; i++)
     {
    $("#hdnTestSeriesId").val(testSeriesId);
    $("#hdnTestId").val(arrTestIds[i]);
    
    
    $("#hdnTestSeriesCode").val(testSeriesIdCode);
    if (testSeriesId != '') {
                    
    var data = { testSeriesId: testSeriesId, testId: arrTestIds[i]};
     $.ajax({
       type: "POST",
       url: '@Url.Action("GetTestProductsTestStandards", "Report")',
       data: JSON.stringify(data),
       dataType: 'json',
       async:false,
       contentType: 'application/json; charset=utf-8',                    
       error: function (result) {
       alert(result);
       },
       success: function (result) {
    //Standard var rowStandard = ''; if (result.standard != '') { rowStandard = "<label><b>Standard: </b>" + result.standard + "</label><br/><br/>"; //Schemees var table = "<table width='100%'><tr><td colspan='2'><hr /></td></tr><tr><td><b>Sample Number</b></td><td><b>Products</b></td></tr>"; var rowScheme = ''; for (i = 0; i <= result.samples.length - 1; i++) { rowScheme = rowScheme + "<tr><td>" + result.samples[i].TestSeriesSampleCode + "</td><td>"; for (j = 0; j <= result.samples[i].TestSeriesSampleProducts.length - 1; j++) { rowScheme = rowScheme + result.samples[i].TestSeriesSampleProducts[j].ProductCode; } rowScheme = rowScheme + "</td></tr><tr><td colspan='2'><hr /></td></tr>"; } rowScheme = table + rowScheme + "</table>"; dv = dv + rowStandard + rowScheme; } } }); } } $("#dvStandardSchemeResultFor").html(dv); }

    Now, when I am taking //Scheme section off, the async ajax is hitting the C# code for all iterations which is correct and I am getting multiple results. But when I am putting the scheme in, I am only getting one set of result.

    1. Standard

    2. Scheme

    It is not hitting the code method again.

    Please help

     

    Thursday, September 15, 2016 3:03 PM

All replies

  • User1724605321 posted

    Hi 666,

    It is not hitting the code method again.

    Do you mean the c# code ? If you use Schemees section , server side code not fire?  Please debug your application to check whether any error occurs on the page.

    If i misunderstood your problem , please feel free to let me know .

    Best Regards,

    Nan Yu

    Friday, September 16, 2016 6:58 AM