Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search


C# - How To Send Json Data To Asmx (from Aspx) Using Jquery

i built contact form in aspx 3.5 and i'm using jquery to send it to web service (asmx).the web service need to return success or error code. the problem is that at the web method i get only single value and not array. I'm kind of new in ajax and i tried a lot of solutions but without any results.. please if you can only explain me the principle of what to do it also be good..this is the client side:


when i debug i see that the input parameter "name" contains only one string - i dont know how to get the full json string that i send to the service and contains all the form data - i want to desirialize it to string array or something like, and process it.

View 2 Replies (Posted: Jun 21 10 at 2:19)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Jquery - JSON Can Call Method In .aspx File But Not In .asmx (web Service) File
I am using JQuery & JSON (POST) to call webmethod. However I can call only webmethod located at aspx file but not in asmx file Below are sample codes

Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Public Class CustomValidate
Inherits System.Web.Services.WebService
<System.Web.Services.WebMethod()> _
Public Shared Function AJAX_Test(ByVal date1) As Boolean...
Return True
End Function
End Class
Javascript: JQuery JSON
function isDates(source, arguments) {
var isValidDate;
type: "POST",
contentType: "application/json; charset=utf-8",
url: "CustomValidate.asmx/AJAX_Test",
data: '{date1: "' + arguments.Value + '"}',
dataType: "json",
async: false,
success: function(result) {
isValidDate = result;
error: function(httpRequest, textStatus, errorThrown) {
alert("status=" + textStatus + ",error=" + errorThrown);
arguments.IsValid = isValidDate;

It always return javascript undefined error. But if I put the AJAX_Test webmethod in aspx page and replace the url: "CustomValidate.asmx/AJAX_Test" to "mypage.aspx/AJAX_Test". It works fine.

Posted: Jul 3 10 at 16:56

View 1 Replies!   View Related
WCF / ASMX :: Send A JSON Data Packet Back To Requester?
We have an exisiting Web Service which receives SOAP requests and returns the data accordingly. However, we have a new project which requires the same information but the Android SDK doesn't support SOAP so we need to use JSON. As JSON is just a data container format, I need to write a new module to replace the SOAP WSDL which receives a querystring from the Android app and then processes the data and returns it in a JSON packet. The problem is that having never used JSON I'm unsure as to how I return the data to the app in JSON format. Does anyone have any examples I can look at in VB.Net or C#?

Posted: Mar 07, 2011 02:10 PM

View 2 Replies!   View Related
Jquery - How To Send JSON Object To Web Service And Process The Data There
I am using the local database in web kit browsers and to get the data from the database I have the following code:

function synchronise() {
function (transaction) {
transaction.executeSql("SELECT * FROM Patients;", [], synchroniseHandler, errorHandler);


Posted: Oct 28 10 at 4:00

View 1 Replies!   View Related
JQuery - ASPX Security Libraries / Looking For A Combo To Send Data From JavaScrpit To ASPX?
i would like to know if there's a combo like jCryption (jCryption) - PHP but for jQuery - ASPX.I mean, I have been searching for a combo to send data both ways (Client-server, server-client) with jQuery to ASPX. The best I found was jCryption that sends data from JavaScrpit to PHP. I need a combo to send data from JavaScrpit to ASPX.

PD: Please don't tell me to use HTTPS, it's not enough to ensure the data communication on a client - server application.

Posted: Jun 6 10 at 6:20

View 1 Replies!   View Related
MVC :: Using json And Jquery To Send A Form To The Controller?
i am using json and jquery to send a form to the controller like below, when i click submit validation occers but line is executed even if form is invlid. How can i tell if form validation failed or succeded using javascript?


Posted: Nov 21, 2010 10:18 AM

View 2 Replies!   View Related
JQuery :: Make Json Call To Send An Email?
the aspx:


the jquery :


The problem is that I need to use the text in a text box in my webmethod, and I can't because it's static, this results in a compilation error:


What can I do ?

Posted: Aug 27, 2010 08:30 AM

View 8 Replies!   View Related
WCF / ASMX :: Write Endpoint To Communicate With JSON From Jquery On Page?
i need to be able to expose information to a page, and I need to write the information in xml on my webserver which will be dynamically created from the database.

I need to use json to pass the data from the screen back to the server two way communication xms back and forth. Is it actually any good using a wcf endpoint to serve the json back to the page and use query with wcf? Is this possible?

Or is it easier to use standard pages .aspx and just do a call to a url and get the json with jquery....

We will probably want to send this information to other locations at some point in the future too....

Posted: Aug 31, 2010 05:22 PM

View 1 Replies!   View Related
AJAX :: Consume .asmx With JQuery (POST Method, Not JSON)?
The ideal goal is to consume .asmx web service using jQuery like this


Posted: Feb 04, 2010 07:47 AM

View 2 Replies!   View Related
WCF / ASMX :: Calling A Remote Or Local Web Service That Returns A JSON With JQuery?
how to create a Web service that returns a JSON(or JSONP). That also should be able to work for cross-domain access aswell as for a local call.. help to get this working or for a few links for further reading about this 

Posted: Mar 16, 2011 05:12 PM

View 2 Replies!   View Related
JQuery :: Returning A Json String From A Webmethod From An Aspx Page?
My Problem is that i am returning a json string from a webmethod from an aspx page.

I want to create a dynamic html table using that json string but found no solution for that.

Can anyone Provide me the solution to generate html table from json string ?

Posted: Nov 27, 2010 07:57 AM

View 6 Replies!   View Related
WCF / ASMX :: Send Output Of Web Service From Xml As An Attachment To An Aspx Page?
i have designed a web service which would create 2 csv files on the system. I want to send the links to the location of the files as an url attachment over the aspx page.

like : http://myserver/download.aspx?file1=C: empimage1.png&file2=C: empimage2.png

the output from the asmx web service is : [Code]....

where is the ipaddress. this is the whole output i get from the webservice.

how do i get the aspx page to send the attachment in the format i mentioned above? I have added an asp website to the project and added the webservice as a web reference to this but i do not know how to get the location from the xml output file of the webservice result.

Posted: Apr 08, 2010 07:27 PM

View 2 Replies!   View Related
Return Data From An Asmx Into JSON?
I want to return an array of javascript objects from my asmx file. ie.

variable = [
*value1*: 'value1',[code]....

I seem have been having trouble reaching this. I'd put this into code but I've been hacking away at it so much it'd probably do more harm than good in having this answered. Basically I am using a web service to find names as people type the name. I'd use a regular text file or something but its a huge database that's always changing - and don't worry I've indexed the names so searching can be a little snappier - but I would really prefer to stick with this method and just figure out how to get usable JSON back to javascript. I've seen a few that sort of attempt to describe how one would approach this but I honestly think microsofts articles are damn near unreadable.

EDIT: I'm using the $.ajax() function from jQuery - I've had it working but it seems like I was doing it in bad practice not returning and using actual JSON. Previously I'd take a string back and insert it into html to use the variable it set - very roundabout.

Posted: Jun 15 10 at 13:11

View 1 Replies!   View Related
WCF / ASMX :: Read Data From Json Web Service?
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:


PS: this is a spin off of another post at: [URL]

Posted: Dec 16, 2010 01:50 PM

View 6 Replies!   View Related
WCF / ASMX :: Return JSON Data From A 2.0 Web Service?
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.

Posted: Sep 10, 2010 12:40 PM

View 3 Replies!   View Related
Send JSON Data To HTTP Handler?
i have an ASP.NET 4.0 HTTP handler that should receive and send data in json format. I'm using jquery to send json objects serialized in a string to the handler. It correctly sends the request but i don't know how i could retrieve the data from the httpcontext passed to the handler and how i could deserialize it..


type: "POST",
url: "myurl.ashx",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: $.toJSON({
success: function (response) {

Posted: Nov 14 10 at 12:48

View 1 Replies!   View Related
WCF / ASMX :: Windows Communication Foundation Service Returning Xml / Json Data?
I Need by service contract to return the xml/json result depending on the request type. function which will convert my result set (i am using linq to sql) so that i do not need to create the xml format for the result set by iterating through the table row many times.What is the suitable way to do that.

I need a kind of short cut method which will convert the table data to xml result.Had i been using mvc i would have been able to generate the xml data by overriding the the ExecuteResult method in the ActionResult and giving Conetnt-Type = "text/xml" as OP.But since i am using Wcf i don't have the controller context(as controller context is the parameter that needs to be passed to Execute Result).

My present code for converting the table data to the xml format is below.

public XDocument UsersLists(string authToken)
bool IsAuthenticated = Authenticate(authToken);
XDocument xDoc = new XDocument();
XElement root = new XElement("Users");


I need to eliminate this way of generating xml for each table records.

Posted: Aug 25, 2010 07:28 AM

View 1 Replies!   View Related
Return JSON Data From ASPX Page?
I am trying to integrate FlexBox It uses JSON data to populate listbox items. It internally calls a server side page with AJAX, and reads the JSON results from that page. for example, $('#flexbox1').flexbox('flexbox-results.aspx'); here, page "flexbox-results.aspx" needs to return JSON result. when I use

Response.ContentType = "application/json";

it does not work.. how to proceed..

Posted: Dec 1 09

View 9 Replies!   View Related
Jquery - Get Json Data In Controller Action?
I have mvc application. i want to configure the object in jquery and want to pass it to the the action of controller . where as in my script i am using this for configure data for the ajax call:


it does not calls to action in controller. i think here :

var json = $.toJSON(peform);

is not working as expect. is it need to add any js file to reference ? or mistake in syntax?

Posted: Feb 9 at 8:33

View 1 Replies!   View Related
Accessing JSON Data From Page Using JQuery
I am trying to load the JSON data that I am getting from an aspx page into a drop down list that I have on another page but I am getting the following javascript error.

Microsoft JScript runtime error: 'SiteID' is null or not an object

The SiteID is not returning null though and I believe that is an object. The following is the code I am using to try and load the data into the drop down list:

$.getJSON('Test.aspx?DepotID=' + DepotID, function (sites) {

Posted: Nov 19, 2010 09:11 AM

View 17 Replies!   View Related
Capture Data From From Using Jquery / Ajax / Json?
i have few textbox on the form and when the user submit i want to capture the data and insert into db

here is what my code looks like

beforeSubmit: function(data)
{ // called just before the form is submitted
var item = $("[id$='item']");
var category = $("[id$='category']");
var record = $("[id$='record']");


Posted: Apr 10 10 at 3:17

View 2 Replies!   View Related
JQuery :: Getting Data Out Of Objects In A JSON Response
I'm working on an MVC2 site that needs to update the values of a select list based on the value selected by a user in another list. This is the response I'm getting from my controller's JSON action:


Posted: Sep 04, 2010 11:46 PM

View 2 Replies!   View Related
JQuery :: Get Data From Databse Using Json With Webservice?
i want to get data from my database and dispaly it in my web page using json with webservicei'm going to post my code i create a webservice and add method which return string to get all data so my code like this


and in my page


Posted: Dec 23, 2010 08:21 AM

View 6 Replies!   View Related
JQuery :: JSON Data Disappears On Call?
I have a problem with a AJAX call I do in a application. It's a MVC application ( c#) with a lot of javascript.

When I do a call from my javascript to a controller (through a ajax call) the call gets to the class and function, but the data isn't there. The data is send in JSON.

I found a few of the same problem but most of the time they used another name voor de parameter then it is in there json.

Here is the code


Posted: Oct 12, 2010 12:31 PM

View 3 Replies!   View Related
JQuery :: To Supply An AntiForgeryToken When Posting JSON Data?
I am using the code as below of this post:First i will an fill array variable with the correct values for the controller action.Using the code below i think it should be very straigtforward by just adding the following line to the javascript:

data["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
The <%= Html.AntiForgeryToken() %> is at his right place and the action has a [ValidateAntiForgeryToken]

But my controller action keeps saying: "Invalid forgery token" 


    data["fiscalyear"] = fiscalyear;
    data["subgeography"] = $(list).pa n


Posted: May 25, 2010 03:36 PM

View 1 Replies!   View Related
JQuery :: Get JSON Call To MVC Controller Not Returning Data
This is probably something simple. The following JQuery call is executing and calling the controller. The controller is executing correctly. I used the sample data that's commented out to verify that the templates were working also. However, the success function is not executing in the browser. Any thoughts or other ways I can debug this?

<script type="text/javascript">$(document).ready( function(){ alert("Here"); @* var myData = [ {first: "Jane", last: "Doe"}, {first: "John", last: "Doe"} ]; *@ $.getJSON( "/User/Filter",function(myData){ $("#myDataTemplate").tmpl(myData).appendTo("#itemContainer"); } ); alert("there");  }
public ActionResult Filter() { var myData = this.repository.GetAllUsers(); //return Json(myData);  return Json(myData, JsonRequestBehavior.AllowGet);}

Posted: Nov 25, 2010 08:11 PM

View 6 Replies!   View Related
Passing Complex JSON Data JQuery To Action?
I have 2 classes that are used to mirror the data from an ajax call. One (Customer) contains a property which is name, and the other is an array of Products.

Public Class Customer
Private _Name as String
Private _Products as Product()
Public Property Name() As String


Posted: Dec 1 10 at 8:13

View 1 Replies!   View Related
JQuery :: Get Data In Json Format Client Side
i Declare  in.cs file

TextBox tb=new TextBox();

and how to get aspx when page is load

<input type="Text" runat="server"/>

using jquery json

Posted: Mar 10, 2011 06:48 AM

View 2 Replies!   View Related
JQuery :: Sending Large Data From Json Based Webservice?
i am using combination of jquery and JSON based webservice in most of projets.  Lately i am facing this problem. if the data returned from webservice is huge    ajax call from jquery fails. yup i know i can implement paging etc etc but is there a way i can increase the limit to get more data from webservice with jquery ajax call?

Posted: Mar 11, 2011 05:26 PM

View 2 Replies!   View Related
JQuery :: How To Save And Retrieve Date In Database Using Jquery Ajex .net ,JSOn,XML,HTML
how to save and retrive  date in database using  jquery ajex ,JSOn,XML

Posted: Oct 13, 2010 01:49 PM

View 2 Replies!   View Related
Creating A Jquery Grid From Json Data That Came Back From An Ajax Request?
i am searching for a way to create a grid (from some kind of jquery grid plugin didnt choose one yet)

anyway i want to call a webmethod and return a json serialized from a List of an object i created.

today i just use a regular grid view inside an iframe

but i want to eliminate that iframe and create those grids with ajax requests.

Posted: Jul 7 10 at 6:49

View 2 Replies!   View Related
JQuery :: Gridview Textbox Template Save Using Jquery Json?
my requirement is i want grridview textbox  template save using jquery json how to do it

Posted: Mar 11, 2011 08:44 AM

View 2 Replies!   View Related
WCF / ASMX :: Can Get Different Json Datasets From The Same Object
I want to serialize an object to json, so I'm using [Code]....


This is fine, but I want to return different json datasets depending on the circumstances. Lets say I have this object (a simplified example):

class foo
[DataMember] int productId
[DataMember] string productName
double price; //not used in json.. yet

Which will serialize to a json object containing the product name & Id, but what if I also need to be able to return a different json object (say, productId and price but not name)? Can this be done somehow in the same object using WCF/DataContracts and DataMembers? This will be sent in an ajax query containing a collection of objects and needs to fast, so just including every member in every type of json request whether it's needed or not isn't a good solution.

Posted: Apr 06, 2010 04:27 PM

View 1 Replies!   View Related
Web Forms :: Send An Image Over JSON From C#?
I am trying to figure out how to send an image to Tuzulo using their api which appears to use JSON (quoted below).  I have figured out how to receive information about what images I have with them and their URLs but cannot figure out how to send an image. 

I have found lots of JSON examples but they all seem to show sending or receiving strings.  Could someone give me a hint?


Private API URLs These URLs require private keys, used for management and extension. To protect each upload, the private key must be known (saved, bookmarked, etc.). With an account, this becomes transparent.



Extend collection.



Manage collection.

Public keys are meant to be shared while private keys are meant to be temporarily bookmarked if necessary. Bookmarking is unnecessary when you're a site member.

Posted: Mar 06, 2010 10:48 PM

View 3 Replies!   View Related
MVC :: How To Send An HTTP-Status 404 Json Or Xml In An MVC Website
i've got some simple Actions that return a JsonAction. nothing tough there. But, if there's a problem (eg. some exceptions are thrown) i wish to throw return certain HTTP status codes, like a 404 (resource not found), 500 (my code is bad and sucks),  401 (not authorised), etc. I got this idea from Twitter,
here. It's not a new thing, but I sorta like it :)

So, i tried making my own IExceptionFilter, called HandleErrorAsJson. That's not too hard, I thought :) I then have that checking for certain (custom) exceptions. Based upon the (custom) exception, it sets the status code. otherwise, it's unhandled and therefor the status code is 500. I'm also trying to send back a json messge, just like twitter... eg. curl



Posted: Sep 16, 2009 07:26 AM

View 5 Replies!   View Related
Define And Send A JSON Object Array?
I'm looking for a way to define and send a JSON object array. I've figured out how to define a single JSON object, turn it into a string and send it, but what about an array of this type? Probably something simple I'm overlooking...

var myColumnSetting = { "ColumnName": name,
"ColumnIndex": index
convert it to a string
var myJSONText = JSON.stringify(myColumnSetting, false);

Posted: May 17 10 at 22:23

View 1 Replies!   View Related
Architecture Switch From Page And JSON ASMX Web Services To MVC
there's an .aspx page that does absolutely nothing in the codebehind, but contains the markup for the page in the Design View. Then we have an .asmx web service that receives requests with JSON content-type. These are called by the JavaScript in the page. This web service returns .NET objects serialized to JSON in response to these JavaScript Ajax HTTP POSTs. I'd like to switch to MVC but am not sure to how switch this architecture. Basically what we're doing is two things:

1) Replying to GET /MyPage.aspx with HTML markup that represents the page
2) Replying to POST /MyPage.aspx/WebMethodName requests with .NET objects serialized to JSON.

It seems like MVC would be a good way to eliminate the need for a Page object (again, the codebehind isn't used--only the HTML markup in the .aspx file is) and an .asmx web service. No? What do I need to start changing to accomplish this switch? Is it straight-forward? Painful? Someone at work already has an MVC page running in the same directory as my Web Forms .aspx and .asmx web service, but I don't see anything in the directory about Routes, so I'm confused. He's got a Views, ViewModels, and Controllers subdirectories.

Posted: Feb 6 10 at 8:13

View 3 Replies!   View Related
WCF / ASMX :: Internet Explorer Downloads JSON To A File
i have a few calls however when i type in the URI into the address bar in internet explorer it prompts me to save the file. However google chrome displays it automatically in the browser page. Does anyone know why this would occur, here is an example of one of my calls;



Posted: Nov 27, 2010 11:11 AM

View 1 Replies!   View Related
WCF / ASMX :: Return A Generic List In Json Format?
how would i go about returning a generic list in json format, can anyone point me to any good examples.

Posted: Oct 30, 2010 06:54 PM

View 2 Replies!   View Related
How To Send A Collection And A Few Other Values In Json Form To A Webmethod?
Upon clicking a button I need to send a collection and a few other variables to server in Json form.For each value in the collection the server code (C# ) wil update those other variables in the DB.

For example there is a ‘classnumber’ collection with values (First, Second, Third, ….),other variables (‘teacher_name’ and ‘subjectname’).For each value in the ‘classnumber’ collection I need to update the ‘teacher_name’ by searching for the ‘subject_name’ in the DB.So I need to pass the ‘classnumber’ collection,’teacher_name’,’subject_name’ values to server in json form. At the moment instead of sending the ‘classnumber’ collection I am sending ‘teacher_name’,’subject_name’,’classnumber’ as variables for each value in the collection ,which requires multiple requests made to the server.

Instead of these individual requests I am wondering if there is a way to send all the data at once to server in json form?

Posted: Sep 28 10 at 12:56

View 1 Replies!   View Related
Copyright © 2005-08, All rights reserved