Search Results

Search found 4 results on 1 pages for 'iboeno'.

Page 1/1 | 1 

  • Passing jQuery object and WebMethod return value to an OnSuccess function

    - by iboeno
    I am calling a WebMethod from this code: if($(this).attr("checked")) { .. MyWebMethod(variable1, variable2, onSuccessFunction); } The MyWebMethod returns an integer, and I want to set $(this).attr("id") of the jQuery object above to the returned integer. Basically, I'm trying to do the equivalent of an MVC Ajax.ActionLink...AjaxOptions {UpdateTargetID =...} However, I can't figure out how to get both a reference to $(this) as well as the returned value. For example, if I do: MyWebMethod(variable1, variable2, onSuccessFunction($(this))); I can succesfully manipulate the jQuery object, but obviously it doesn't have the return value from the MyWebMethod. Alternatively, the first code block with a method signature of onSuccessFunction(returnValue) has the correct return value from MyWebMethod, but no concept of the jQuery object I'm looking for. Am I going about this all wrong?

    Read the article

  • jsonp cross domain only working in IE

    - by iboeno
    EDIT: At first I thought it wasn't working cross domain at all, now I realize it only works in IE I'm using jQuery to call a web service (ASP.NET .axmx), and trying to us jsonp so that I can call it across different sites. Right now it is working ONLY in IE, but not in Firefox, Chrome, Safari. Also, in IE, a dialog pops up warning "This page is accessing information that is not under its control..." Any ideas? Here is the code: $.ajax({ type: "POST", url: "http://test/TestService.asmx/HelloWorld?jsonp=?", dataType: "jsonp", success: function(data) { alert(data.prop1); }, error: function(XMLHttpRequest, textStatus, errorThrown) { alert(XMLHttpRequest.status + " " + textStatus + " " + errorThrown); } }); And the server code is: [ScriptService] public class TestService : System.Web.Services.WebService{ [WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public void HelloWorld() { string jsoncallback = HttpContext.Current.Request["jsonp"]; var response = string.Format("{0}({1});", jsoncallback, @"{'prop1' : '" + DateTime.Now.ToString() + "'}"); HttpContext.Current.Response.Write(response); } }

    Read the article

  • Problems using jQuery $.ajax to pass data

    - by iboeno
    I'm using ASP.NET and attempting to call a method with a signature of [WebMethod] public static string GetInfo(string id){...} using the following javascript: var elementValue = $("#element").attr('id'); var d = "{id : " + elementValue + "}"; $.ajax({ type: "POST", url: "../WebPage.aspx/GetInfo", data: d, contentType: "application/json; charset=utf-8", dataType: "json", success: function(msg) { //do this } }); And this is not working. If instead I set elementValue = 2; it works fine. If I try to hardcode in a string value for testing purposes e.g. elementValue = "nameToLookUp"; It fails. Why is this happening, and how do I resolve it? On a side not, why is type: required to be POST instead of a GET? In the end I just want to pass a string value I want to look up in a DB and retrieving some json data.

    Read the article

  • asp.net mvc jQuery $.post works but $.get doesn't

    - by iboeno
    Why would POST work but not GET? I'm not using [AcceptVerbs(HttpVerbs.Post)]. I'm calling this: public ActionResult GetTest(string key) { var test = new { HelpTest = key }; return Json(test); } And it works when I do this: $.post("/Home/GetTest", { key: options.key }, function(helpTest) { alert(helpTest.HelpTest); }); But not this: $.get("/Home/GetTest", { key: options.key }, function(helpTest) { alert(helpTest.HelpTest); }); Why would this be? Using GET returns an XMLHttpRequest.status of 500. What am I confused about?

    Read the article

1