<script type="text/javascript"> var Type; var Url; var Data; var ContentType; var DataType; var ProcessData; function WCFJSON() { debugger; var MobileNo = $("#txtMobileNo").val(); var TokenID = $("#txtTokenNumber").val(); //alert(Data); // var JSONObject = { "GetClientDetailFromPrimary": { "tokenid": "" + TokenID + "", "MobileNo": "" + MobileNo + ""} }; Type = "GET"; //Url = "http://localhost:12344/SecondaryToPrimaryRESTful.svc/JSON/GetClientDetailFromPrimary/" + $("#txtTokenNumber").val() + "/" + $("#txtMobileNo").val(); // Url = "http://localhost:12344/SecondaryToPrimaryRESTful.svc/JSON/GetClientDetailFromPrimary/MobileID/09898345474"; // Url = "http://localhost:12344/SecondaryToPrimaryRESTful.svc/JSON/GetClientDetailFromPrimary"; Data = '{"tokenid": "' + TokenID + '","MobileNo":"' + MobileNo + '"}'; // Data = '{"MobileNo":"' + MobileNo + '"}'; //Data = JSON.stringify(Data); ContentType = "application/json; charset=utf-8"; DataType = "json"; ProcessData = true; CallService(); } //function to call WCF Service function CallService() { $.ajax({ type: Type, //GET or POST or PUT or DELETE verb url: Url, // Location of the service data: Data, //Data sent to server contentType: ContentType, // content type sent to server dataType: DataType, //Expected data format from server processdata: ProcessData, //True or False success: function (msg) {//On Successfull service call ServiceSucceeded(msg); }, error: ServiceFailed// When Service call fails }); } function ServiceFailed(result) { debugger; alert('Service call failed: ' + result.status + '' + result.statusText); Type = null; varUrl = null; Data = null; ContentType = null; DataType = null; ProcessData = null; } function ServiceSucceeded(result) { debugger; if (DataType == "json") { $('#<%=txtClientID.ClientID %>').val(result.client_id); $('#<%=txtFundID.ClientID %>').val(result.fund_id); $('#<%=txtClientName.ClientID %>').val(result.client_name); $('#<%=txtFundName.ClientID %>').val(result.fund_name); $('#<%=txtPrimaryName.ClientID %>').val(result.contact_name1); $('#<%=txtPrimaryContact.ClientID %>').val(result.contact_mobile1); } } function ServiceFailed(xhr) { alert(xhr.responseText); if (xhr.responseText) { var err = xhr.responseText; if (err) error(err); else error({ Message: "Unknown server error." }) } return; } $(document).ready(function () { // $("#btnSubmit").click(function () { var mobileNo = $("#txtMobileNo").val(); if (mobileNo == "") { alert(">> Mobile No. cannot be blank."); } else { WCFJSON(); } return false; }); }); </script>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)