0
function GetSelectedTextValue() { 
    var selMenu = document.getElementById("selMenu"); 
    var selMenuValue = selMenu.value; 
    var selOptions=document.getElementById("selOptions"); 
    var selOptionsValue = selOptions.value; 
    var UserInput=$("#txtClaimNumber").val(); 
    if(selMenuValue=="Claims_Related" && selOptionsValue=="1") { 
        Claim_related_api(UserInput); 
    } 
}

function Claim_related_api( Claim_number) {
    var model = { PolicyNumber: "236426891", ClaimNumber: Claim_number };

    $.ajax({
        type: "Post",
        data: JSON.stringify(model),                
        url: 'http://asplb-dev-00433/api/ClaimDetailsByClaim',
        dataType : "json",
        contentType: "application/json"

    }).done(function (res) {               
        alert(res[0].CLAIM_ID);

    });
}
Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
  • how you are calling function `Claim_related_api` ? share that code too. Also did you get any error in your browser console? share that too – Alive to die - Anant Nov 02 '17 at 07:19
  • function GetSelectedTextValue() { var selMenu = document.getElementById("selMenu"); var selMenuValue = selMenu.value; var selOptions=document.getElementById("selOptions"); var selOptionsValue = selOptions.value; var UserInput=$("#txtClaimNumber").val(); if(selMenuValue=="Claims_Related" && selOptionsValue=="1") { Claim_related_api(UserInput); } } – aditya tyagi Nov 02 '17 at 07:20
  • from this method i am calling the Claim_related_api function – aditya tyagi Nov 02 '17 at 07:20
  • [Please read how to ask a good question](https://stackoverflow.com/help/how-to-ask) – Alive to die - Anant Nov 02 '17 at 07:22
  • no am not getting any errors, its just that when the debugger reach the ajax code it reaches to the end and it shows res as undefined. – aditya tyagi Nov 02 '17 at 07:22
  • 2
    add success and error callback functions and attach debugger in them and check whether it is success or fail. – Makarand Patil Nov 02 '17 at 07:24
  • will you attach that as i am new to jquery and ajax – aditya tyagi Nov 02 '17 at 07:24

1 Answers1

0

you can use like this

function Claim_related_api( Claim_number) {
    var model = { PolicyNumber: "236426891", ClaimNumber: Claim_number };



    $.ajax({
        type: "Post",
        data: JSON.stringify(model),                
        url: 'http://asplb-dev-00433/api/ClaimDetailsByClaim',
        dataType : "json",
        contentType: "application/json",
        success: function (response) {
            console.log(response);

        },
        error: function () {
            console.log(error);
        },
    });

}
Jinesh
  • 1,554
  • 10
  • 15