Jump to content
Sign in to follow this  
rhishi20

not able to call asmx webservice from javascript function

Recommended Posts

Dear friends,

 

Basic need

--------------

 

I need to call asmx webservice from javascript function. onbuttonclick, i am actually calling that javascript function. line with high size font is the problem area.

 

 

please help guys working from past 5 days on this part

 

WebService Registration with aspx page---------------------------------------------------
<form id="form1" runat="server">
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePageMethods="true">
<Services>
<asp:ServiceReference Path="~/dataPreExist.asmx"/>
</Services>
</asp:ToolkitScriptManager>

 

 

WEBSERVICE

------------------

<ToolboxItem(False)> _
Public Class dataPreExist
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function EnqPreExistOrNot(ByVal paraCcn As String, ByVal paraPcode As String) As Boolean
Dim strsql6 As New StringBuilder
Dim localdt6 As New DataTable
' ccn = "DJ079"
' party = "04BSPT0066"
With strsql6
.Append("select * from complaintmastercrm where ccncd='" & paraCcn & "' and partycd='" & paraPcode & "'")
End With
localdt6 = CommonDb.ReturnDataTable(strsql6.ToString, "CRM")
If localdt6.Rows.Count > 0 Then
EnqPreExistOrNot = True
MsgBox("pre Enquiry Exist")
MsgBox("Pre Enquiry not exist")
Else
EnqPreExistOrNot = False
End If
End Function
End Class
End Namespace
Javascript Function
-------------------------
function webServiceCall() {
var paraCcn;
//var paraPartyCd;
var paraPcode;
//alert('hello last')
paraCcn = document.getElementById("<%=lblCcn.clientID%>").innerHTML;
paraPcode = document.getElementById("<%=hdnParty.clientID%>").value;
paraPcode = paraPcode.replace(/,s*$/, "");
var a = new namespace1.dataPreExist();
//not working block
a.EnqPreExistOrNot(paraCcn, paraPcode, OnSucessorFail);
//not working block
}
function OnSucessorFail() {
debugger;
var proceed;
proceed = confirm("Enquiry already Generated for this Machine and Cost Center");
if (proceed == true) {
return true;
}
else {
return false;
}
}

 

 

 

Share this post


Link to post
Share on other sites

I have placed debugger in webservice but while debugging, debugger not going inside webservice.

 

is there any other method of debugging webservice(asmx webservice) if possible, please suggest ?

 

even if i place script debugger inside function OnSucessorFail() which is a javascript function it is not going inside that function.

 

before calling below mentioned webservice, all javascript code above this webservice call works fine, but webservice call is not working for me and also javascript after it.

 

a.EnqPreExistOrNot(paraCcn, paraPcode, OnSucessorFail);

 

 

is this webservice call is right ?

 

you can see i have placed confim box in javascript which has to come after successful execution of mentioned webservice which is not happening in my case.

Edited by rhishi20

Share this post


Link to post
Share on other sites

I don't have enough experience with .net to suggest how to debug a web service, I was just suggesting that you check your developer console for Javascript error messages. The code you highlighted as not working is inside a Javascript function, so I would start there.

Share this post


Link to post
Share on other sites

I have placed script debugger before

 

a.EnqPreExistOrNot(paraCcn, paraPcode, OnSucessorFail);

 

in javascript function and dubugged it through developer console it give me error:

 

Failed to load resource: the server responded with a status of 500 (Internal Server Error)

http://localhost:1188/dataPreExist.asmx/jsdebug

Share this post


Link to post
Share on other sites

A 500 response means that the server-side code had a fatal error, that's what you need to debug.

Share this post


Link to post
Share on other sites

To JustSoemGuy:

 

I have solved it by another way but not by using webservice, i have used postback of one of the dropdown to finish the work at server side. and then call javascript function on Button Click.

 

thanks for the help.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...