JQuery UI Autocomplete WebService Source Returning JSON?

Nov 29, 2010

I have been trying for two months to get this code working, and I am close, but still confused. I want the JQuery UI Autocomplete function to call an web service which returns JSON data and display that data for selection, and on selection put the selected value into a hidden field.

There are several issues:

1) The autocomplete function is not firing
2) The source: "/AutoSuggest.asmx/DOTFind?" line throws an invalid object exception
3) The service requires two parameters: (string prefixText, int count) - count tells it how many records to return.
4) I am not at all certain that this code will accept JSON data that comes back from the service

Here is the code:

[code]....

View 4 Replies


Similar Messages:

JQuery Autocomplete Not Working With Webservice?

Mar 24, 2011

I have this code:

$('#' + textboxID).autocomplete({ delay: delay, source: ["cats", "dogs"] });
which works fine.
I want to use a webservice:
$('#' + textboxID).autocomplete({ delay: delay, source: webserviceURL});
This doesn't work. My webservice URL is /blah/blah.asmx/myMethod
The webservice definition is:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public List<string> myMethod(string term)
{
// Logic here, return list of strings
}

The method never gets called. Can anyone point me in the right direction? I have other webservices in the same .asmx which work fine with other controls (other controls are using $.ajax to call them).

Edit: Getting closer, I now get a 500 error saying Request format is unrecognized for URL unexpectedly ending in '/myMethod'. I think it's not treating my url quite right..

View 2 Replies

JQuery :: Get JSON Call To MVC Controller Not Returning Data

Nov 25, 2010

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"); }
);</script>
//Controller
public ActionResult Filter() { var myData = this.repository.GetAllUsers(); //return Json(myData); return Json(myData, JsonRequestBehavior.AllowGet);}

View 6 Replies

JQuery :: Returning A Json String From A Webmethod From An Aspx Page?

Nov 27, 2010

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 ?

View 6 Replies

Jquery - WebMethod Returning JSON But The Response Obj In $.ajax() Callback Is Only A String

Mar 8, 2011

public class JsonBuilder
{
private StringBuilder json;
public JsonBuilder()
{
json = new StringBuilder();
}
public JsonBuilder AddObjectType(string className)
{
json.Append(""" + className + "": {");
return this;
}
public JsonBuilder Add(string key, string val)
{
json.AppendFormat(""{0}":"{1}",", key, val);
return this;
}
public JsonBuilder Add(string key, int val)
{
json.AppendFormat(""{0}":{1},", key, val);
return this;
}
public string Serialize()
{
return json.ToString().TrimEnd(new char[] { ',' }) + "}";
}
}

Here is the Web Method [WebMethod]

public static string GetPersonInfo(string pFirstName, string pLastName)
{
var json = new JsonBuilder().AddObjectType("Person");
json.Add("FirstName", "Psuedo" + pFirstName).Add("LastName", "Tally-" + pLastName);
json.Add("Address", "5035 Macleay Rd SE").Add("City", "Salem");
json.Add("State", "Oregon").Add("ZipCode", "97317").Add("Age", 99);
return json.Serialize();
}................

View 1 Replies

JQuery :: UI Autocomplete Not Passing Correct Querystring To Ashx Webservice?

Dec 29, 2010

Setup: I have a RadioButtonList with two listitems (One Street, the other Schools). These define what type of search I want. I textbox with associated autocomplete. First you select which search to complete, and then start typing and the autocomplete will make . Autocomplete goes out to ashx webservice which pulls a list from the database.

I have tested the webserver and it works properly, so I'm thinking the problem is with my jQuery UI autocomplete. <div id="divSelectOne" style="padding:8px 3px 8px 3px; border-bottom:1px dotted #cccccc; background:#f9f9f9;"> <span style="font-weight:bold; color:#369;">Select One:</span><br />
<asp:RadioButtonList ID="radSelect" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text=" Street, City, Zip or Subdivision" Value="Street" Selected="True"></asp:ListItem>
<asp:ListItem Text=" School" Value="Schools"></asp:ListItem>

[Code]....

View 2 Replies

JQuery :: Get Data From Databse Using Json With Webservice?

Dec 23, 2010

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

[Code]....

and in my page

[Code]....

View 6 Replies

JQuery :: Compute JSON In JTemplate In Webservice Manually?

Mar 31, 2011

I have a webservice which retrieves data from another external service. The data is already in JSON Format. So I retrieve it and set it to the return value (type: string) of my webservice. But according to firebug the webservice then encapsulates the provided JSON-Data with a backslash, e.g. it returns:

[Code]....

instead of

[Code]....

But the JSON provided by the external service is correct. So how could I provide the correct string to jTemplate from my Webservice?

View 4 Replies

AJAX :: How To Bind DataList Using JQuery Json And Webservice

Jun 27, 2012

I try lots. we can bind asp.net gridview many ways but datalist i not able to bind. How can I bind asp.net datalist using jquery/json and webservice.

View 1 Replies

Make A JQuery Ajax Call To A Webservice That Needs To Return JSON

Jun 19, 2010

Actually I am trying to learn jQuery Ajax calls to asp.Net webservices.

I have been trying to call the webmethod below:

[code]....

Do I need to serialize my object in some way before setting the 'data' attribute, so that I can call $.ajax() function?

View 2 Replies

Jquery - Iterate Through JSON Object List Provided By Webservice?

Nov 24, 2010

I have an ASP.NET webservice method that returns a generics list (List'<'Construct>) serialized as JSON, using code such as this:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class TestService : System.Web.Services.WebService {
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetOccupationListJSON(int SOCLevel)
{
Construct NewConstructList = new ConstructList();
DataContractJsonSerializer serializer = new DataContractJsonSerializer(ConstructList.GetType());
MemoryStream ms = new MemoryStream();

[Code]....

I assumed (from looking elsewhere) that accessing the JSON data through the index would provide me with access to the underlying object at that index, so that I can then work with it to access its properties.
However, when i=0 and I do var Construct = data[i]; I get the character at the i position of the data array ([), and in the next iteration I get the second character ({). So clearly I am accessing the elements of a string array rather than the JSON data object.How do I make sure that the data returned by the webservice gets into proper JSON format, so that I can iterate through the object elements within it?

View 1 Replies

JQuery :: Sending Large Data From Json Based Webservice?

Mar 11, 2011

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?

View 2 Replies

MVC :: Returning A Function In JSON?

May 26, 2010

I would like to return an function in some JSON. How can I stop my function being output as text (how can i stop it being wrapped in quotation marks?).

eg: [Code]....

In script the value of name is just a string. Is there some object I can set name to that will wrap my script and emit as script not a string?I want to do this to better control the "remote" rule of jQuery validate. I have my own dataannotationmodelvalidator for it and its doing this atm:

[Code]....

Which is working fine for the most part except I can't get the value of 'name' to be a function. It comes out as a string. Alternatively is there someway to control what JSON serializer this thing is using alternatively. We need a wrapper function so you can do something like:

name = Emit("function(){ return $(this).val(); }")

and have it come out as script not a string.

View 6 Replies

MVC :: Returning Pure Json From An App?

Aug 2, 2010

I want to return pure JSON from an MVC 2 Action. How can i do this?

View 4 Replies

Using JQuery AutoComplete Plugin - Submit On Autocomplete?

Feb 17, 2011

I'm using jQuery AutoComplete Plugin in ASP.Net as outlined in the article below, so that as a user types in a .Net textbox they get a list of options to choose them. This works fine, but what I need to do now is call a server side function when the user has finished typing or has choosen a value, rather than the user having to submit the value by pressing a button.

View 2 Replies

Returning Data To Client-side Autocomplete Query?

Jan 28, 2010

I'm using a JQuery plugin [URL] to add auto-completion to a "city" textfield. The component calls an ASP.NET page that simply loads an array of all possible city values (>8000) and then iterates that array returning those that start with the text the user has so far entered.

The thing is, it's pretty slow in real use. It lags behind what the user types to the extent that most of the time the user probably won't notice that it's there.

So, my question is, how can I speed it up?

I had thought that an array would be a better way to go than putting the data in a database and having to hit that multiple times. Do others agree that having this information hard-coded is the way to go given that it's not at all volatile and needs to be all about speed of return?

If so, what would you look at to improve the speed of performance? Should I be caching the data on application start and accessing it from memory? Would I be better off instead with multiple arrays, each containing values starting with a particular letter so I can go straight to the relevant one and thus iterate a much smaller array? Or am I missing a much more obvious way to go about this?

View 3 Replies

MVC JSON Actions Returning Boolean?

Sep 20, 2010

I had my ASP.NET MVC actions written like this:

//
// GET: /TaxStatements/CalculateTax/{prettyId}
public ActionResult CalculateTax(int prettyId)
{
if (prettyId == 0)
return Json(true, JsonRequestBehavior.AllowGet);
TaxStatement selected = _repository.Load(prettyId);
return Json(selected.calculateTax, JsonRequestBehavior.AllowGet); // calculateTax is of type bool
}

I had problems with this because when using it in jquery functions I had all sorts of error, mostly toLowerCase() function failing.

So I had to change the actions in a way that they return bool as string (calling ToString() on bool values), so that thay return "true" or "false" (in the qoutes) but I kinda don't like.

How others handle such a case?

View 1 Replies

Returning A JSON View In Combination With A Boolean?

Apr 13, 2010

What i would like to accomplish is that a partiel view contains a form. This form is posted using JQuery $.post. After a successfull post javascript picks up the result and uses JQuery's html() method to fill a container with the result.

However now I don't want to return the Partial View, but a JSON object containing that partial view and some other object (Success -> bool in this case).

I tried it with the following code:

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int id, Item item)
{
if (ModelState.IsValid)
{
try
{

[Code].....

However I don't get the HTML in this JSON object and can't use html() to show the result. I tried using this method to render the partial as Html and send that. However this fails on the RenderControl(tw) method with a: The method or operation is not implemented.

View 2 Replies

Create Autocomplete In Gridview Without Using Webservice?

Dec 15, 2010

how to create autocomplete in gridview without using webservice.

View 2 Replies

WCF / ASMX :: Returning Xmldocument From Webservice

Sep 17, 2010

Ive created a webservice that returns an xmldocument

[WebMethod]
public XmlDocument Invoke()
{
//code here
}

when I add a webreference to a consuming project, the return type is classed as XMLNode, anyone know why?

View 1 Replies

C# Webservice Returning Docx File?

Nov 8, 2010

I have some xml data. I've made an asp.net soap based webservice that takes the xml as a byte buffer applies xsl transformation to it and converts it to a docx file. But when i return the docx file using the response object i get an error that client found response of type application/vnd-word but it was expecting text/xml.

Service Snippet to push document file after xsl transformation

Context.Response.Clear();
Context.Response.ClearHeaders();
Context.Response.ContentType = "application/vnd.openxmlformats- officedocument.wordprocessingml.document";
Context.Response.AddHeader("Content-Disposition", "attachment; filename=" + "test.docx");
Context.Response.Flush();
Context.Response.End();

View 3 Replies

WCF / ASMX :: WebService Returning Pdf File?

Jul 8, 2010

I am using C# 2.0. I am trying to create a webservice that returns a pdf file.

I tried this:

[Code]....

Is this the correct way? I am not getting any errors, but want to know, if this is correct.

View 6 Replies

AJAX :: Autocomplete Extender With External Webservice?

Apr 1, 2010

I am using autocomplete extender in my project with the external webservice. The problem what I am facing is I need to pass credentials to connect to the webservice, as this service is hosted in different domain.

View 4 Replies

Sql - Configure Data Source Is Not Returning Anything?

Jun 12, 2010

I'm selecting table data of the current user:

SELECT [ConfidenceLevel], [LoveLevel], [HappinessLevel] FROM [UserData] WHERE ([UserProfileID] = @UserProfileID)

I have set a control to the unique user ID and it is getting the correct value:

HTML: <asp:Label ID="userID" runat="server" Text="Labeluser"></asp:Label>

C#: userID.Text = Membership.GetUser().ProviderUserKey.ToString();

I then use it in the where clause using the Configure Data Source window unique ID = control then controlID userID(fills in .text for me)

I compile and run but nothing shows up where the table should be.

Here is the code it has created:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ConfidenceLevel" HeaderText="ConfidenceLevel"

[Code]....

View 1 Replies

WCF / ASMX :: Windows Communication Foundation Service Returning Xml / Json Data?

Aug 25, 2010

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 asp.net 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");

[Code]....

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

View 1 Replies







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