MVC :: Not Getting Value From Json

Oct 21, 2010

I have written a code that go to controller using json and get the date from controller. Every thing works fine when running locally, but when i deploy my application to server, i am not getting the data returned from controller using jsonreturn. One more thing My firewall has blocked the GET. So how to resolve this.

//On Page
var URL = "/Home/AsyncGetCheapestList/" + param;
$.getJSON(URL, null, function(data) {
// displaying data content ;
});
//On controller
public JsonResult SetServiceIdServiceName(string asyncInputs)
{
List<string> st = new List<string>();
st.Add("one");
st.Add("two");
st.Add("three");
st.Add("four");
return Json(st,JsonRequestBehavior.AllowGet );
}

Here GET is blocked by my firewall so unable to get the data. Is that any other way to get it.

View 1 Replies


Similar Messages:

Javascript - How To Make Json Child Nodes (JSON Inside JSON)

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

Read An External JSON File Using Json.NET On Page Load?

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

Json Value Undefined When Converting Datatable Into Json Format?

Feb 1, 2010

I want to retreive the data from database and assign it to dropdownlist. For that I'm using the following jquery in the onclick event

[Code]....

View 1 Replies

How To Convert JSON String To JSON Object Using JavaScript

Jan 21, 2011

I use the JavaScriptSerializer class of ASP.net to serialize my object and return it to the client side. How can I deserialize the string using JavaScript?

View 4 Replies

C# - Converting Json String Into Json On Client Side?

Apr 4, 2011

In my javascript code I am getting json string from cs file

var tmpString="<%=resultset2%>";

In cs I am concatenating strings to build json string. Here is an issue the json string is returned as a string and it has " with it.

"[{id:'1',name:'Aik'},{id:'2',name:'Aik or Aik'}]"

Because of " in beginning and end javascript code treat it as a string.

View 2 Replies

Implementing JSON Feed On Web Application With JSON.NET?

Nov 18, 2010

I've been tasked with implementing a JSON feed on an asp.net website that will be consumed by 3rd party apps (such as IPhone, Android, etc) and I'd like to follow best practices.

An example of what I'd like to achieve would be something similar to: [URL]

I've chosen the JSON.net api as this seems to be highly recommended.

My Google-fu must be failing me as I can't find a single full example code for an Asp.net web application with JSON.net implemented on it, so I've no real concept of where to begin.

My question is fairly simple:

Should I create this sort of feed as an ASPX, or ASHX file? Or even a .NET Web Service? (Remember that the tools that will be using this feed are on external apps like IPhones, etc)

I created a test feed in both ASHX and ASPX format ... here is the code (I'm using Subsonic to populate the collection) ... are either of these along the correct lines?

ASPX:

[Code]...

View 2 Replies

How To Put Data In A Var As A JSON

Jan 13, 2011

If I have in my db a table called User with name, Id, age fields and I want to get these data and put it in a var as a JSON serialize, then I want to send it to javascript page to reform it as I want . I need to know how to put these data in a var as a JSON, how to read the data in the javascript file (how to deal with each one. for example : array[name]?

which thing is more better to deal with these data in asp.net code then send it in the javascript or to send it to the javascript and then to deal with ?

View 2 Replies

Push Out JSON In Mvc 2?

Dec 27, 2010

I have a response object which I want to convert to Json, but somehow I can't, propably beacuse of I cannot the framework too well. I'm trying to convert a anonymous object to json but somehow it doesn't go so well. I would preferably do it in JSON than just make a text/plain result. In my controller: ViewData["json"] = new { Ok = false }; In my view: <%: ViewData["json"] %>

In my js-code (ajax-callback) I get back the following: { Ok = False } Which ain't what I am excepting. I want the { ok : false } or else js doesn't recognize the property in the object as a boolean. Or are there some better way to push out json-data? EDIT I did a method in my controller with a JsonResult instead of Actionresult.

var obj = new
{
Ok = false,
Message = ""
};
return Json(obj);

And that's the object I'm pushing out. And like this in js: {"Ok":true,"Message":""} C# 4.0 and Javascript goes along so well

View 1 Replies

How To Convert The Datatable To JSON

Mar 30, 2011

I'm trying to populate the slickGrid with an ajax call.

Code:
<script type="text/javascript" >
$(document).ready(function() {
var params = {};

[code]...

my function returns a datatable. But I need to convert the datatable to JSON.

View 28 Replies

Jqgrid Using Json Datatype?

Jul 23, 2010

i am jqgrid which is binded dynamically using json datatype.my problem is with pageing.

I wrote the script for jqgrid in AddCategory.aspx and redirected this page to AddCategoryGrid.aspx where i wrote the code for binding jqGrid data.

It is displaying all records in one page but not allowing the pagging.

[code]....

View 1 Replies

How To Consume JSON From A Web Service

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

MVC Return Json Result?

Feb 4, 2011

I have a controller that uploads a file. I would like to return a json result with bool success (if successfully uploaded otherwise false) and message (this could be error message that occured OR link to a file OR link to an image, depending on what was uploaded).What's the best way to approach thisI have this

public class UploadedFile
{
public bool Success { get; set; }
public string Message { get; set; }
}

then In my controller I would set Success to true/or/false and Message to <a href OR <img am i on the right track?How would i then parse this in the view so that when image it will show an image, if link show a link, if error simply alert error.

View 2 Replies

How To Read This JSON String

Nov 3, 2010

I am getting this JSON string from an ASP.Net webservice:

{"d":{"Table":[{"col1":123,"col2":"name","col3":"name","col4":100,"col5":"/Date(1153033200000)/"},{"col1":123,"col2":"name","col3":"name","col4":101,"col5":"/Date(1153033200000)/"},{"col1":123,"col2":"name","col3":"name","col4":102,"col5":"/Date(1153033200000)/"}]}}

In my jQuery how do I reference the Table code so I can loop through the data?

msg.d[i].col1
What am I missing? msg.d.table[i]?

View 4 Replies

MVC :: Getting Exception With JSON Web Service With 2.0.0.0?

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

MVC :: How To Get Datetime From Json Object

Oct 21, 2010

I am calling an action from JQuery using $.getJSON() method.

This action returns a JsonResult object.

I am getting all the values correctly but not the Date Format.

Below is the Date format which i am getting.

/Date(1287587195000)/
/Date(1287587195000)/

But i want it like "10/15/2010 11:56 AM" this format.

How can i achieve it...

View 1 Replies

How To Get A Method To Return Json In C# And MVC 2 Or 3

Nov 16, 2010

i use JSon to return allot of results when building a website, but find myself writing a a lot of code like this:

[Code]....

and then simply call this function with whatever IEnumerable results i have my question is would i be on the right lines here, what would be the best possible way to do this as it makes no sense to be writing in MVC and OOP but to keep rewriting code to just FROM ?

View 5 Replies

How To Return JSON In A Webservice

May 27, 2010

[code]....

What's wrong?

Edit: And what if I need to return {Message:'',Type:1} ?

Edit2: The answer for the last one is: I can return a Dictionary<string, string>

View 2 Replies

Two Objects In Same Json Return?

Nov 16, 2010

I have Categoreis and Locations I would like return both in one method. How can make a use of both Categories.ToList() and Locations.ToList()? What type of object should I return?

View 1 Replies

How To Compress JSON From PHP And Decompress In C#

Sep 27, 2010

I am having a problem passing JSON from PHP server and ASP.NET server.

I am getting Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 48 bytes)

I am looking for a way to compress the JSON.

View 4 Replies

MVC :: Json And Jquery With Dropdownlist?

Sep 28, 2010

I want to do like below:I have three dropdownlist:

- test
- test1
- test2
and i have two textbox
- txtname
- txtsex

when i click on test dropdown list i want to diplay data in test1 dropdownlist and display in txtname and txtsex too, how can i do by using mvc json and jquery ?

View 2 Replies

AJAX :: .Net 3.5 JSON And WCF Serialization?

Feb 12, 2010

I'm trying some WCF ajax.net 3.5 out for the first time, and I'm having some difficulties. I have a WCF Service which I have connected to in my aspx page using <asp:ScriptManager>. I have a custom object which has been decorated as a [DataContract]. I'm calling the object from javascript successfully, I can see the JSON response in FireBug, but Sys.Serialization.JavaScriptSerializer.deserialize() chokes on it. I'm sure I'm making a noob mistake, but I used up all my patience getting the Web.Config values right for running the WCF service.

Here's a mockup of what I'm doing.

[Code]....

View 3 Replies

WCF And Json / Wrong Serialization

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

Could Not Deserialize JSON Object

Feb 23, 2010

We are trying to consume WCF service which returns employee details in JSON Format.

like:

{"d":[{"_type":"Employee:#","BigThumbNailURI":null,"ID":1,"Name":"E1"},{"_type":"Employee:#","BigThumbNailURI":null,"ID":2,"Name":"E1"}]}

From VB.net code behind when I am trying to deserialize it it's stating that

"Expecting state 'Element'.. Encountered 'Text' with name '', namespace ''."

Deserialization code snippet:

Dim serializer = New DataContractJsonSerializer(GetType(List(Of Employee)))
Dim memoryStream = New MemoryStream()
Dim s = msg.Content.ReadAsString()
serializer.WriteObject(memoryStream, s)
memoryStream.Position = 0.......

View 2 Replies

How To Loop Through JSON Data

Aug 16, 2010

I have an ashx page that returns the following JSON data that I would like to be able to loop through and add to values to a bunch of li's in a ul.

My question is how do I loop through to retrieve the values.

The data that is returned from the ashx look slike this

{"ImageCollection":
{
"Images":
[
{
"ImageID":"62",
"CatID":"1",......

I get a single alert that says undefined. What am I doing wrong?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved