forum

home / developersection / forums / using ajax method call

Using Ajax method call

Manoj Bhatt 1699 17-Nov-2014

i have this aspx view : 

 jQuery('#addjob').click(function () {
            if ($('#metier').val().length > 0) {
                $('.taglist').append('<li style="line-height: 20px"><a href="" style="width:250px" >' + $('#metier').val() + '<span class="icon-remove"></span></a></li>');
                $.ajax({
                    type: "POST",
                    url: "JobsEdition.aspx/AjouterMetier",
                    data: "{'job': '" + $('#metier').val() + "'}",
                    success: function (msg) {
                        AjaxSucceeded(msg);
                    },
                    error: AjaxFailed
                });
                                              }
            $('#metier').val('');
        });

In the code behin i put this method : 

 public partial class JobsEdition : System.Web.UI.Page
    {
      List<string> jobs = new List<string>();
        [WebMethod()]
        public void AjouterMetier(string job)
        {
            if (job != "")
            {
                jobs.Add(job);
                Session["jobs"] = jobs;
            }
 
        }
}

I'm beginner in the use of ajax in Asp.net, so i had always the session variables Session["jobs"] null and the method AjouterMetier was never reached . 

What is the error that I commited?

How can i fix it?


Updated on 17-Nov-2014
Manoj Bhatt

Other


Message
Can you answer this question?

Answer

1 Answers

Liked By