Click here to Skip to main content
15,909,503 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to can call web method in the page with ajax
address is webservice.rgraga.com/GetNews
parametr is Id
Posted
Updated 14-Jul-15 21:11pm
v2

1 solution

XML
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
<script type = "text/javascript">
function ShowCurrentTime() {
    $.ajax({
        type: "POST",
        url: "CS.aspx/GetCurrentTime",
        data: '{name: "' + $("#<%=txtUserName.ClientID%>")[0].value + '" }',
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: OnSuccess,
        failure: function(response) {
            alert(response.d);
        }
    });
}
function OnSuccess(response) {
    alert(response.d);
}
</script>
 
Share this answer
 
v2
Comments
Mohibur Rashid 15-Jul-15 3:11am    
Why are you assuming that his request is going to be POST?
Thanks7872 15-Jul-15 3:32am    
When OP assumes that we can understand everything without any detailed explanation, it is ok to assume something.
Lakhan Anjana 15-Jul-15 3:35am    
thanks Rohan
Lakhan Anjana 15-Jul-15 3:16am    
whatever but he can call method with little home work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900