Click here to Skip to main content
15,885,182 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
XML
<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: "Bind/BindDatatable",
            data: "{}",
            dataType: "json",
            success: function (data) {
                for (var i = 0; i < data.d.length; i++) {
                    $("#gvDetails").append("<tr><td>" + data.d[i].UserId + "</td><td>" + data.d[i].UserName + "</td><td>" + data.d[i].Location + "</td></tr>");
                }
            },
            error: function (result) {
                alert("Error");
            }
        });
    });
</script>


After Page Loading Error will came ...plz help me...
url: "Bind/BindDatatable",
------>how to write this line code
iam using web forms....
Posted
Comments
F-ES Sitecore 2-Jun-15 11:52am    
What error? What line? What is "Bind/BindDataTable"? Google "call asp.net webmethod from jquery" and you'll find example webmethod and jquery code to do this, and go from there.
iamvinod34 2-Jun-15 12:05pm    
bind is asp webform page name and Binddatatable webmethod name
--->url:bind.aspx/Binddatatable is current process but this not excuted
iam writing url:bind/Binddatatable ---->
error: function (result) {
alert("Error");
} excuted
sir
:)
Mathi Mani 2-Jun-15 13:07pm    
Your url seems incorrect. You have to give the correct url. For example, if you have a aspx page called Bind that has BindDatatable method (this method had to be marked as web method in Bind.aspx.cs), then the url should be like:
url:"Bind.aspx/BindDatatable".
iamvinod34 2-Jun-15 13:09pm    
ok, but iam using webform pages
sir
Mathi Mani 2-Jun-15 13:49pm    
As far as I know, Asp.Net Web forms are the ones with .aspx extension as I mention in my comment. If you are talking about something else, do share that info.

1 solution

1.This is code when you need to save the value on button click using json

$("#btnApprove").click(function () {

$.ajax({
url: "@Url.Action("IsApprove", "ControllerName")",
data: JSON.stringify({ 'requestId': requestId, 'referenceNumber': referenceNumber, 'userId': userId, 'value': value, note: $("#Custom.text").val() }),
cache: false,
type: 'POST',
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (data) {
window.location.reload(data);
}
});
});
 
Share this answer
 

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