Skip to main content

Home/ .Net Developers/ Group items tagged ajax

Rss Feed Group items tagged

Tarik Guney

Using jQuery with ASP.NET: Part 2 - Making Ajax Callbacks to the Server - 1 views

  • $.getJSON(url,data,callback) Similar to $.post(), but expects the result to be JSON which is automatically deserialized into a Javascript value and passed to the callback as a parameter.
  • $.getJSON() also doesn’t support JSON POST data – only POST encoded variables
  • Specifically inside of a master page you might find that the ID gets mangled by ASP.NET into: ctl00_Content_txtSymbol. I could change my code to read: { symbol: $("#ctl00_Content_txtSymbol").val() }   which works, but is pretty ugly and volatile because the parent IDs might change if a container is renamed or moved around.   Another option is to use a little server side script markup to embed the ClientID: { symbol: $("#<%= txtSymbol.ClientID %>").val() } This is also ugly, but reliable. But this does not work if you end up moving your code into a separate .js script file. If you use client ids like this a lot you might create a list of them as global variables:   var txtSymbolId = "<%= txtSymbol.ClientID %>"; which then lets you reuse the variable a little more easily:   { symbol: $("#" + txtSymbolId).val() }   These variables are also visible in loaded script files.
  • ...4 more annotations...
  • $.getScript(url,callback) This function loads script code from the server and executes it once downloaded if no callback is specified
  • An optional callback can be provided to be notified with the server result text when the callback completes which is useful if you want to visually adjust the retrieved content – like applying an effect to visually cue the user to an update. Note this function is heavily overloaded: If no URL is specified .load() acts as a load event handler that fires when an element has loaded its data (ie. an image or script).
  • This function is useful for simple JSON results returned from arbitrary services, but not usable for calling WCF or ASMX ASP.NET services since they expect JSON POST input
  • here also a number of global Ajax events that you can take advantage of all of which take callbacks as parameters: ajaxCallback(), ajaxError(), ajaxSend(), ajaxStart(),ajaxStop(),ajaxSuccess(). These are useful for setting up global handlers that can centrally manage Ajax requests. You’re not likely to need these much unless you build components that need to know status of requests.
  •  
    Rick Strahl is introducing the best document ever, how to make ajax callbacks to asp.net applications ( asmx,wcf and asp.net) this article shows us how easy to use jQuery Ajax with asp.net and how powerful over Asp.NET Ajax Framework.
Tarik Guney

JavaScript Kit- Ajax Reference (XMLHttpRequest object) - 0 views

  • Ajax is a popular term used to describe asynchronous (versus synchronous) requests made from the client to the server. In JavaScript, Ajax requests are handled using the XMLHttpRequest object, which lets you open a connection, send the request, then handle the data returned by the server seamlessly in the background.
  •  
    Complete XMLHttpRequest reference.
  •  
    Complete XMLHttpRequest reference.
Tarik Guney

Robust ASP.NET control referencing in JavaScript | Encosia - 0 views

  • The better solution is to use inline ASP.NET code to inject the control’s ClientID property:
  • $get('<%= TextBox1.ClientID %>')
  •  
    How to get ClientID property in asp.net inline scripting to avoid complex asp.net clientid scheme.
Tarik Guney

Using complex types to make calling services less… complex | Encosia - 0 views

  • One unfortunate anti-pattern that often emerges in this situation is a service method with too many parameters:
  •  
    Dave Ward shows us how to pass json Objects to Asp.net and create their counterparts on server which makes creating things easily on asp.net part.
  •  
    Dave Ward shows us how to pass json Objects to Asp.net and create their counterparts on server which makes creating things easily on asp.net part.
1 - 5 of 5
Showing 20 items per page