Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok my problem is next, this is my script...
XML
<script type="text/javascript">
        $(document).ready(function() {
            $.ajax({
                type: "POST",
                url: "Kategorije.aspx/CartState",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                data: { },
                success: function (msg) {
                    $("#ispis").text(msg.d);
                }
            })
        });
    </script>

and here's method i'm calling

C#
public static int CartState()
   {
       DatabaseEntities db = new DatabaseEntities();

       var rez = from p in db.PrivremenaKorpa
                 where (p.SessionID == HttpContext.Current.Session.SessionID)
                 select p;
       return rez.Count();
   }


using firebug and request happens, but this is what i get as response from firebug:

Unknown web method CartState.
Parameter name: methodName

Now, i want to call "CartState" once page is loaded, and replace the div's content (Div "ispis") with the page method's return.
I'm kinda new with this, so any help would be appreciated.
Posted
Comments
pradiprenushe 2-Apr-13 1:41am    
CartState is webmethod?
pradiprenushe 2-Apr-13 1:46am    
Try this link http://www.stereoplex.com/blog/asp-net-ajax-and-unknown-web-method.
http://www.webcosmoforums.com/asp/17939-unknown-web-method-parameter-name-methodname-500-internal-server-error-asp-net.html
Add scriptmethod above function.
Milos12 2-Apr-13 9:47am    
tyvm :)

1 solution

Thx for your help guys, its solved...the problem was here:

C#
[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
    public static int CartState()
    {
        DatabaseEntities db = new DatabaseEntities();

        var rez = from p in db.PrivremenaKorpa
                  where (p.SessionID == HttpContext.Current.Session.SessionID)
                  select p;
        return rez.Count();
    }


just need to add this line of code above CartState:

[WebMethod, ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = false)]
 
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