none
Share Point 2013,How to stop the previous Rest call if drop down value has changed? RRS feed

  • Question

  • HI ,

    Share Point 2013, I have a drop down  with all Share point Groups.If i choose as Group 1 then load all group members into the table. If i will immediately change the drop down value to Group 2, still my table is loading with the Group 1 members.

    How should i cancel/Stop the previous rest call and proceed with present changed value to fill the table?

    If possible provide the code with Good styles to header and scroll bars if data is more.

    Tuesday, September 4, 2018 3:12 PM

All replies

  • Hi

    when you change the drop down value to Group2, it should make another request.

    If you want to one call at one time, I think you can freeze the drop down control when calling the service.


    Justin Liu Office Servers and Services MVP, MCSE
    Senior Software Engineer
    Please Vote and Mark as Answer if it helps you.

    Wednesday, September 5, 2018 5:10 AM
  • Can you please provide the code to freeze the Drop down ?
    Wednesday, September 5, 2018 7:38 AM
  • Hi,

    Here is the code snippet for your reference:

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script>
    $(function(){
    $("#btnClick").click(function(){
    var requestUri = _spPageContextInfo.webAbsoluteUrl + "/_api/web/sitegroups/getbyname('" + $("#myselect").val() + "')/users?$select=Title,Email";
    $.ajax({
    url: requestUri,
    type: "GET",
    headers: {
    "accept":"application/json;odata=verbose",
    "content-type": "application/json;odata=verbose",
    "X-RequestDigest":$("#_REQUESTDIGEST").val()
    },
    success: onSuccess,
    error: onError
    });
    function onSuccess(data) {
    var items = data.d.results;
    var results='';
    for (var i = 0; i < items.length; i++) {           
    results+=items[i].Title + " : " + items[i].Email +'\n';       
    }
    console.log(results);
    }
    function onError(error) {
    alert(JSON.stringify(error));
    }
    });
    });
    </script>
    
    
    the Group Name:<br>
    <select id="myselect">
    
    <option value="Group1">Group1</option>
    
    <option value="Group2">Group2</option>
    
    <option value="Group3">Group3</option>
    
    </select>
    <input type="button" id="btnClick" value="Get All Members From SharePoint Group"/>
    

    In the Rest Request sitegroups getbyname endpoint, it will get the dropdown list value as the group name to filter members.

    Thanks

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Wednesday, September 5, 2018 7:55 AM
  • Hi

    You can't stop the first request in SharePoint.

    But you can do it when you get the request data.

    You can add group information in request data.

    And you can compare the request data and dropdown value.

    You can change the group member if they are the same.

    And don't change the group member if they are different.

    I think it can resolve your problem.


    Please remember to mark the replies as answers if they helped.
    Linyu - SharePoint Engineer
    QQ Group: 72637444

    Wednesday, September 5, 2018 8:07 AM
  • Hi,

     

    I am checking to see how things are going there on this issue. Please let us know if you would like further assistance.

     

    You can mark the helpful post as answer to help other community members find the helpful information quickly.

     

    Thanks

     

    Best Regards


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Tuesday, September 11, 2018 1:45 AM