C# - Can't Load JSON Into A Jstree From WCF Service (or How To Find What's Wrong When Jstree Stays On "loading...")
Nov 25, 2010
I am trying to get jStree (jQuery tree control) working in my ASP.NET (C#) page. I'm using a WCF service to return a test string of JSON. Opening the WCF service URL in the browser works fine - If I go to the URL (http://localhost/website/GetTree) I get the JSON (looks just like opening XML in browser, with syntax highlighting and collapsible tab thingys)
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">{"attr": { "id": 2, "rel": "default" }, "data": "A node", "children": [ { "data": "Child 1", "attr": { "id": 43, "rel": "document" } }, {"data": "Child 2", "attr": { "id": 25, "rel": "document"} } ] }</string>
jstree itself works fine - if I put the same JSON in "manually" in my document.ready like so:
"json_data": {
"data":
[{
"attr": { "id": 2, "rel": "default" },
"data": "A node",
"children":
[{
"data": "Child 1", "attr": { "id": 43, "rel": "document" }
},{
"data": "Child 2", "attr": { "id": 25, "rel": "document"}
}]},{
"attr": { "id": "li.node.id", "rel": "document" },
"data": {
"title": "Long format demo",
"attr": { "href": "#" }
}}]},
I get the tree appearing with those nodes in it.
But, combining the two:
"json_data": {
"ajax": {
"url": "GetTree",
"data": function (n) {
return {
};
}
}
},
fails. The jstree shows up as just the word "loading..." and an animated loading gif. And it does hit a breakpoint inside the WCF service method (just like browsing to it does).
A: An idea where I've gone wrong?
B: An idea how I find out what's wrong? jstree documentation was no , and I can't see any error messages.
Update: solved
[Code]....
View 1 Replies
Similar Messages:
Jun 30, 2010
I gotta problem with the new version of jstree by using this part of code, at the first execution ,the data function returns the root node.the problem is that this code never executes again. so what ever happens, I just have the root node. dose any body know any solutions??
$('#tree').jstree(
json_data: {
ajax: {
url: '<%=url %>',
dataType: "json",
data: function (n) {
return {
"id": n.attr ? n.attr("id") : 0
};
}
}
},
themes: { url: '/ThirdParty/jquery/jsTree/themes/', theme: "default", dots: true, icons: true },
plugins: ["json_data", "themes", "ui"]
})
{
View 1 Replies
Sep 10, 2010
Currently, I'm using an AJAX Handler to populate the JSTree:
$(function () {
$("#jstree").jstree({
"json_data": {
"ajax": {
"url": "AJAXHandler.aspx?action=GetMenu"
[Code]...
The idea here is to bind the move_node to a function that will hit the handler and update the database as to where I moved the object. I've been able to create the bind to do that. The problem, however, is that I can't seem to obtain the ID. I'm setting it in the attributes in the population of the JSON object, but when I do a watch on the NODE and REF objects via console.log, the id field is empty.
View 2 Replies
Sep 13, 2010
I currently have a JSTree all set up to do the creation and renaming of a new node:
.bind("create_node.jstree", function (NODE, REF_NODE) {
$.ajax({
async: false,
cache: false, [code]...
The problem is that my success doesn't seem to get hit when I return an integer ID on the create node, thus I can't set it to a global variable. What exactly do I need to return in the function to get back the ID from the server? I'm simply returning a new integer right now.
View 1 Replies
Sep 9, 2010
I'm using the jsTree jQuery plugin and want to execute code when the user double clicks a node.
I can't seem to get it to work. I found some documentation on a ondblclk event but it doesn't fire.
browser.jstree(
{
plugins: ["themes", "json_data", "ui", "cookies"],
callback:
{
ondblclk: function (node, tree) {
if (!thisReportBrowserthis._isFoldersOnly) {
var f = node;
}
}
}
}
);
How can I handle double click events with jstree?
View 2 Replies
Aug 4, 2010
when I load the web page the image's file size stays the same rather then reduce.
[Code]....
View 54 Replies
Feb 2, 2010
Why this WCF 3.5 method
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Json
{
[OperationContract]
[WebGet(ResponseFormat = WebMessageFormat.Json)]
public string Upper(string text)
{
return text.ToUpper();
}
}
returns {"d":"TEXT"} ?
It should returns {"TEXT"}
I'm calling using jQuery.
$("#upper").click(function() {
$.ajax({
type: "GET",
url: "/Json.svc/Upper?text="+$("#input1").val(),
success: function(data) {
$("#input1").val(data.d);
}
});
});
View 2 Replies
Dec 29, 2010
I have a text file named gisQuery129.json that is created using Json.NET - [URL] There is an example on how to create a JSON file and I have done that successfully, but I want to read the file on a page load event and add the values to .NET textbox controls for input values in a query. The created file looks like the following:
{
"myData": {
"randomNumber": "129",
"Application": "MyMapApp",
"FeatureId": "ALL",
"Feature": "ALL",
"spatialQuery": "FEATURE_ID= '11111' AND REQ_SEQ_NUM= 1 AND RAND_PARAM= 129 OR FEATURE_ID= '22222' AND REQ_SEQ_NUM= 2 AND RAND_PARAM= 129"
}
}
I want to read the data in the above sample JSON data and then populate my textboxes something like this:
txtRandParam.text = "129"
txtApplication.text = "MyMapApp" and three more text boxes after that.
View 4 Replies
Aug 1, 2010
I have a weird thing happening. I have two identical databases installed on one virtual machine but under two different instances of SQLServer. For some reason, periodically when saving from one it will save to the other instead. Using debug, I have verified that the connection string is correct and when the item saves, it still saves to the wrong database.I use session variable, and am of the belief that it might have something to do with it...and t hat when I go from one to the other it is still getting the connection string form the other for some reason.To make sure that it isn't a problem, I make sure that I completely close out one database before opening the other in a new IE window.I assume that when I completely close out an internet explorer window that it abandons all session states. Is that true?
View 7 Replies
Oct 7, 2010
We have a web application providing a service using a simple REST interface (GET/POST methods) and returning results in JSON format.
A client wants to use the service from an ASP application (I assume ASP.NET) and asks for example code.
Is there any standard/widely-acceptable procedure for consuming JSON based web services from an ASP.NET application? I'm not familiar with the .NET framework, but can work my way through C#.
View 2 Replies
Feb 8, 2010
I am getting an exception with the JSON Web Service with MVC 2.0.0.0.
Earlier it worked.
The code:
[Code]....
The exception:
[Code]....
View 10 Replies
May 1, 2010
What are the pros and cons of the following 2 cases: Case I: Traditional way: Add service reference in project. Create object and Get data from service on server side and bind to asp.net grid. Case II: Update Service for JSON behavior. Add service reference in project. Call service from javascript to get data. Bind data to jquery grid. Which one is the best approach and why?(Not developer point of view)
View 2 Replies
Feb 13, 2010
I have developed a wcf service for asp.net ajax client. It includes the following steps.
(1) Created WCF sevice contract with the operation "DoWork()" which will take string as input and retun string as output.
(2)Implemented the above operation contract(attributed the implementation class with aspnetcompatibility requirement as enabled).
(3)Added the webscriptenabled to endpoint in web.config file.
(4)Hosted the wcf servie.
(5)Downloaded the javascript file from the service.(e.g.,http://localhost/service1.svc/js)
Client
(1)Opend new asp.net webapplication.
(2)Added the downloaded .js file.
(3)Given the scripts path for ajaxscript manager as both .js file and service url.
e.g
<asp:ScriptManager
ID="id1"
runat="server">
<Scripts>
<asp:ScriptReference
Path="http://localhost:3443/Service1.svc/js/"
/>
<asp:ScriptReference
Path="~/js1.js"
/>
</Scripts>
</asp:ScriptManager>
(4)With this I am unable to call service method
View 2 Replies
Jan 6, 2011
I just want that when i enter name in Textbox1 it shown in TextBox2 when i click on Button
I am using HTML page here's the code
<input id="txtID" type="text" /><br />
<input id="txtName" type="text" /><br />
<input id="btnShow" type="button" value="Show" />
[Code]....
But when i load this Web Page its show this error after click on button
Error: 12031 unknown
Error: 500 Internet Server Explorer
View 18 Replies
Sep 6, 2010
I have a ASP.NET MVC 1.0 app.I have a listbox on the page and I want to pass an array to the webpage so that
javascript can use the array to do some processing depending on the item picked in the listbox.So I thought the best way is to pass JSON data to the webpage on load.So what is the best practice on how to do this?Can you please give me a brief step by step process.How do pass the array as JSON and how do I access it by index?
View 1 Replies
Aug 11, 2010
I try to use the jquery + json to get all elements in form and build a JSON var to post in a ASP.NET MVC method.
[Code]....
It method get all fields in a form and build a JSON, but it dont put JSON inside JSON.
Example:
If i have the follow form:
<input name="person.name"><input name="person.age"><input name="person.address.street">
The serialized string build a JSON like this
{ "person.name": "??", "person.age": "??", "person.address.street": "??" }
I need a plugin or some function to generate like this:
{ "person": { "name" : "??", "age" : "??", "address":{ "street": "??" } } }
View 1 Replies
Dec 16, 2010
I'd like to read data server-side from a web service that outputs in json format. I haven't found any good examples that don't use jquery and are server-side.
Specifically I'm looking at the "weight" field from this api:
[URL]
PS: this is a spin off of another post at: [URL]
View 6 Replies
Sep 10, 2010
Just ramping up on JSON and JQuery and returning data to a ASP.NET web page from a web service using Ajax. The JQuery part is pretty straight-forward. However, when trying to return JSON formatted data instead of XML from a 2.0 web service, I'm stuck. The web service does have the System.Web.Script.Services.ScriptService attribute, so I can hit it via JavaScript; however, the web service always...always...returns data in XML format, no matter if I explicitly say I want JSON as the datatype in my JQuery code. So I don't know if this is an issue with the web service or the JQuery code. I posted this here, but realize that the category could be incorrect depending on where the issue is. Is there no way to return JSON data from a 2.0 web service? It's a production web service, so I can't change the code unfortunately.
View 3 Replies
Mar 9, 2010
I have an containing a list of divs that jQuery turns into progress bars. On .ready, I build a list of all of these progress bars and for each one, call a webservice that gets a value indicating how full the progress bar should be. In order to do this, I need to pass the ID of the div to the web service.
Because the divs are inside a ListView, I manually set the id to be id="completionbar_<%# Eval("MilestoneID") %>"
However, when I pass this id into my web service, it comes up as "undefined" every time. When I view the source, it looks like it's set correctly.
Here's the jQuery that calls my web service:
<script type="text/javascript" language="javascript">
$(document).ready(function() {
$(".MilestoneCompletion").progressbar({ value: 0 });
$.each($(".MilestoneCompletion"), function(index, barDiv) {
[Code].....
I'm thinking maybe the script is executing before the DIV id is set by the ListView databind?
View 2 Replies
Sep 1, 2010
I still can't seem to get this to work.I've tried string arrays object arrays dictionaries. I might be formatting my JSON incorrectly however I am using the labs_JSON plugin. If I remove my data and test the webservice it calls correctly. The : My code looks as follows :
HTML :
<div style="display: block; float: left;">
<asp:Repeater ID="rptMenuRecipeCategories" runat="server">
<HeaderTemplate>
<div class="recipeChecklistHeader">Menu Recipe Categories</div>
[Code]....
View 2 Replies
Aug 24, 2010
Does the script service means creating a webservice in asp.net?
View 1 Replies
Aug 10, 2010
After much head scratching as to why my returned Json string is breaking JSON.parse, I have realized that it is the returned dates that it doesn't like.
.net property:-
[code]....
View 2 Replies
Mar 21, 2011
As I am getting Problem while hosting WCF Service on Win 2003 Server.As it is working fine in my local P
View 1 Replies
Oct 29, 2010
As it is now I create a JavaScript object and then stringify it, put it in a hidden textbox and my code behind can read this string. I then use JSON.NET to parse the string which works fine. I now try to use ajax to post it to my web service but have some issues with how to send the string. I have tried many ways but gets the common errors like
Invalid JSON primitive: myString.
So I checked this out [URL] and it works with hard coded values but I want to use a variable.
JavaScsript to create the object:
for (var i = 0; i < results.rows.length; i++) {
var row = results.rows.item(i);
var customer = new Object();
customer.id = row['id']
customer.name = row['name']
var customerString = JSON.stringify(customer);
$.ajax({
type: "POST",
url: "synchronise.asmx/synchroniseCustomers",
data: "synchroniseCustomers: " + customerString,
contentType: "application/json; charset=utf-8",
dataType: "json",
error: function (xhr, status) {
alert("An error occurred: " + status);
},
success: function (msg) {
alert("success");
}
});
}
WebMethod:
public void synchroniseCustomers(string customerString)
{
JObject o = JObject.Parse(customerString);
string id = (string)o["id"];
string name = (string)o["name"];
If I use data: '{ FirstName: "Dave", LastName: "Ward" }'
in the example above it works but I wish to pass on a string instead.
View 2 Replies
Jul 7, 2010
I want to make a web servcie(.svc) that returns JSON data after entering the input.....which is resulted as in the downloaded filein JSON format.i want something like that-http://209.62.6.226/GracoRest/service.svc/Rest/WheretoBuyplease help me for the above but....step by step...i m trying WCF very 1st time
View 3 Replies