Santosh Kumar

Santosh Kumar

  • NA
  • 126
  • 59.8k

Unable to Call Web Services Method Using Jquery Ajax Call

Jul 31 2014 5:49 AM
Hi,

I am trying to call a web service(.asmx) method  present in same solutions itself(I am using Visual Studio 2012 Web Express) using Jquery Ajax Calls,  I am getting failure error message as '500 Internal Server Error '. Please tell me what changes I need to make In web configue or in any other place.
 
 
 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.2.js"></script>
$(document).ready(function () {
$("#btnUploadFile").click(function (e) { $.ajax({
type: 'POST',
url: "UploadEmployee.asmx/Test",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
alert(msg);
}
,
error: function (response) {
alert(response.status + " " + response.statusText);
}
});
});
});
 
 
 
 using System; 
using
System.Collections.Generic;
using
System.Data;
using
System.Data.OleDb;
using
System.Globalization;
using
System.IO; using System.Linq;
 using
System.Web; using System.Web.Script.Services;
 using System.Web.Services;
namespace
FinanceWebApplication.WebServices
 
{
/// <summary> /// Summary description for UploadEmployee
/// </summary> [WebService(Namespace = "http://tempuri.org/")]
 [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
 [System.Web.Script.Services.ScriptService]
 public class UploadEmployee : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
 public string Test()
{
return "Hi";
 }
}
 

Answers (2)