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);
});
}
Asked
Active
Viewed 142 times
0

Alive to die - Anant
- 70,531
- 10
- 51
- 98

aditya tyagi
- 1
- 1
-
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
-
2add 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 Answers
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
-
@aditya tyagi : Add `debugger;` in both success and error and check in console which function is hit. – Makarand Patil Nov 02 '17 at 07:29
-
debugger is going in error function and giving error is undefined. – aditya tyagi Nov 02 '17 at 07:31
-
change the line `error: function ()` to `error: function (error)` and check it – Makarand Patil Nov 02 '17 at 07:34
-
check this out : https://stackoverflow.com/questions/5241088/jquery-call-to-webservice-returns-no-transport-error – Makarand Patil Nov 02 '17 at 07:42