smackdown000
New Member
I've done some searching online and can't seem to figure this out. How do I force the response to be just JSON? web.config \[code\]<httpHandlers> <remove path="*.asmx" verb="*" /> <add path="*.asmx" verb="*" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" /></httpHandlers>\[/code\]ajax\[code\]function get_data() { var objdata = http://stackoverflow.com/questions/14587469/new Object; objdata.tool ='1'; objdata.product = 'Something'; objdata.details = '9'; objdata.bogus = 'should not pass validation'; var server = 'http://crossdomainserver:87'; var webMethod = '/LogInfo.asmx/LogInfo?'; var url = server + webMethod + "tool=" + objdata.tool + "&" + "product=" + objdata.product + "&" + "details=" + objdata.details + "&" + "bogus=" + objdata.bogus; $('#url').html("<p>" + url + "</p>"); $.ajax({ url: url, cache: false, dataType: "jsonp", contentType: "application/json; charset=utf-8", success: function (data) { $('#get').html("<p>" + data + "</p>"); }, error: function (e) { } }); $('#result').html("<p>" + result.statusText + "</p>"); }\[/code\]webservice\[code\]' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.<System.Web.Script.Services.ScriptService()> _<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _<ToolboxItem(False)> _Public Class LogInfo Inherits System.Web.Services.WebService <WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _ Public Function LogInfo() As String 'do database/error logic here Return jsonreturn.ToString End Function End Class\[/code\]response\[code\]<?xml version="1.0" encoding="utf-8"?><string xmlns="http://tempuri.org/">{"tool":"1","product":"Something","details":"9","user":"username","systime":"1/29/2013 10:20:50 AM","site":"Somewhere, AZ","team":"000000000","result":"1"}</string>\[/code\]