I am try to call my web service with ajax call but i am not get success to call web service with it please find below code
Web Method Which i am trying to call
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;
using System.Collections.Generic;
/// <summary>
/// Summary description for Jasonexample
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class Jasonexample : System.Web.Services.WebService {
public Jasonexample () {
//Uncomment the following line if using designed components
//InitializeComponent();
}
[WebMethod]
public string HelloWorld(Dictionary<string,object>Input) {
return "Hello World " + Input["FName"].ToString() + " " + Input["LName"].ToString();
}
[WebMethod]
public string test ( )
{
return "test";
}
}
My ajax call javascript
/// <reference path="jquery-1.2.3.min.js" />
$(document).ready(function() {
dict = new Object();
dict["FName"] = "Abhishek";
dict["LName"] = "Hingu";
$.ajax({
type: "POST",
url: "Jasonexample.asmx/HelloWorld",
data: '[{"Key":"FName","Value":"Abhi"},{"Key":"LName","Value":"Hingu"}]',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg) {
alert("Hello");
alert(msg);
},
fail:function(msg)
{
alert("fail");
}
});
});
Now any one can you tell me how to pass dictionary collection in ajax called