Note that there are some explanatory texts on larger screens.

plurals
  1. PO.ajax call returns undefine in .net?
    primarykey
    data
    text
    <p>I am trying to build vb.net web app by using mongodb as database. App needs consuming web service and return JSON string. which is used as data source for Kendo UI chart.</p> <p>My web service:-</p> <pre><code> Imports MongoDB.Bson Imports MongoDB.Driver Imports MongoDB.Driver.Builders Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.Web.Script.Services 'Imports System.Web.Script.Serialization Imports System.ComponentModel Imports System.IO Imports AjaxControlToolkit ' To allow this Web Service to be called from script, using ASP.NET AJAX,'uncomment the following line. &lt;System.Web.Script.Services.ScriptService()&gt; _ &lt;System.Web.Services.WebService(Namespace:="http://tempuri.org/")&gt; _ &lt;System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)&gt; _ &lt;Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()&gt; _ Public Class WebService_BufferFile Inherits System.Web.Services.WebService Dim connectionString As String = "mongodb://localhost" Dim client = New MongoClient(connectionString) &lt;WebMethod()&gt; _ Public Function BufferFile_Power(ByVal UserId As Integer, ByVal DataBaseName As String, ByVal Collection As String, ByVal FileDate As DateTime, ByVal FileName As String) As String '&lt;ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=False)&gt; _ 'runner = Mongo2Go.MongoDbRunner.Start() 'runner.Import(strDatabase, strCollection, ImportFilePath, False) 'MongoImportExport.Import("C:\MongoDB\bin\", 27017, strDatabase, strCollection, ImportFilePath, False) Dim ImportFilePath As String = "E:\SCADA\RAW\" &amp; DataBaseName &amp; "\" &amp; Collection &amp; "\" &amp; Format(FileDate, "yyyy") &amp; "\Buffer\" &amp; FileName &amp; "" If File.Exists(ImportFilePath) Then Dim ImportProcess As New Process() ImportProcess.StartInfo.UseShellExecute = True ImportProcess.StartInfo.CreateNoWindow = True ImportProcess.StartInfo.WorkingDirectory = "C:\MongoDB\bin" ImportProcess.StartInfo.FileName = "mongoimport.exe" ImportProcess.StartInfo.Arguments = " --db " &amp; DataBaseName &amp; " --collection " &amp; Collection &amp; "_" &amp; Format(FileDate, "yyMMdd") &amp; "_" &amp; UserId &amp; " --type csv --file " &amp; ImportFilePath &amp; " --headerline" ImportProcess.Start() ImportProcess.WaitForExit(1500) ImportProcess.Dispose() Else Return 0 Exit Function End If Dim server = client.GetServer() Dim database = server.getDatabase(DataBaseName) Dim UserCollection = Collection &amp; "_" &amp; Format(FileDate, "yyMMdd") &amp; "_" &amp; UserId Dim Docs As MongoCursor = database.GetCollection(UserCollection).FindAll() Docs.SetSortOrder(SortBy.Ascending("timestamp")) Docs.SetFields(Fields.Include("timestamp", "converter_UL1", "converter_UL2", "converter_UL3", "converter_I1", "converter_I2", "converter_I3").Exclude("_id")) Docs.SetLimit(3000) Dim JsonString = Docs.ToJson If Docs.Count &gt; 0 Then Docs.Database.DropCollection(UserCollection) End If 'Dim jsonSearializer As New JavaScriptSerializer() 'Return jsonSearializer.Serialize(JsonString) 'Return 234 Return JsonString End Function End Class </code></pre> <p>HTML Page:-</p> <pre><code>&lt;link href="CSS/kendo.common.min.css" rel="stylesheet" /&gt; &lt;link href="CSS/kendo.dataviz.min.css" rel="stylesheet" /&gt; &lt;link href="CSS/kendo.default.min.css" rel="stylesheet" /&gt; &lt;script type="text/javascript"&gt; &lt;/script&gt; &lt;script src="Scripts/jquery-1.7.1.min.js"&gt;&lt;/script&gt; &lt;script src="Scripts/kendo.all.min.js"&gt;&lt;/script&gt; &lt;table border="0" align="center"&gt; &lt;tr&gt; &lt;td class="auto-style1" &gt; &lt;div id="BufferPowerChart" class="k-content"&gt; &lt;div class="PowerChart-wrapper" style="margin: auto;"&gt; &lt;div id="PowerChart"&gt;&lt;/div&gt; &lt;/div&gt; &lt;script&gt; function createPowerChart() { $.ajax( { type: 'POST', url: '/WebService_BufferFile.asmx/BufferFile_Power', contentType: 'application/json; charset=utf-8', dataType: 'json', data: '{"UserId":174,"DataBaseName":"ChitraDurga","Collection":"NSLHK-06","FileDate":"05/05/2013","FileName":"NSLHk-06_b130505_1819.txt"}', async: false, success: OnSuccess, error: OnError }); function OnSuccess(PowerChartData) { alert(PowerChartData.d); var PowerChartDataSource = JSON.parse(PowerChartData.d); $("#PowerChart").kendoChart({ title: { text: "Power" }, legend: { visible: true, position: "bottom" }, dataSource: PowerChartDataSource, series: [{ type: "line", field: "converter_UL1", name: "converter_UL1" }, { type: "line", field: "converter_UL2", name: "converter_UL2" }, { type: "line", field: "converter_UL3", name: "converter_UL3" }, { type: "line", field: "converter_I1", name: "converter_I1" }, { type: "line", field: "converter_I2", name: "converter_I2" }, { type: "line", field: "converter_I3", name: "converter_I3" }], categoryAxis: { field: "timestamp", labels: { rotation: -5 }, majorGridLines: { visible: true } }, valueAxis: { max: 1500, line: { visible: true }, majorUnit:100, minorGridLines: { visible: true } }, tooltip: { visible: true, template: "#= series.name #: #= value #" } }); } function OnError(msg) { alert('Error = ' + msg.d); } } $(document).ready(function () { //debugger; setTimeout(function () { createPowerChart(); }, 500); }); &lt;/script&gt; &lt;style scoped&gt; .PowerChart-wrapper, .PowerChart-wrapper .k-chart { height: 520px; width:850px; } &lt;/style&gt; &lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>Any help would be appreciated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload