This Question have 3 answers right now.

In JQuery, using ajaxSend to preview the url built by $.post call

Tags: ajax jquery

How can I construct my ajaxSend call, this seems like the place to put it, to preview what is being passed back to the broker? also, can I stop the ajax call in ajaxSend? I can perfect my url string before dealing with errors from the broker?

This is the complete URL that, when passed to the broker, will return the JSON code I need:


This is my $.post call (not sure it is creating the above url string)

$(function() {
  function() {
     url: "http://csewebprod/cgi-bin/broker" ,
     datatype: "json",
     data: {
      'service' : myService,
      'program' : myProgram,
      'section' : mySection,
      'start' : '09/08/08',
      'end' : '09/26/08'
     error: function(request){
      $("#updateHTML").removeClass("hide") ;
     success: function(request) {
      $("#updateHTML").removeClass("hide") ;
      $("#updateHTML").html(request) ;
    }); // End post method
   }); // End bind method
  }); // End eventlistener



An easy way to preview the HTTP request being sent is to use Firebug for Firefox. Download and enable the plugin, and when the request is made it will show up in the firebug console.

By : sirwart

API/1.2/Ajax has information on how to bind to AJAX events.

// Hook into jQuery's ajaxSend event, which is triggered before every ajax
// request.
$(document).ajaxSend(function(event, request, settings) {
  // is either a query string like "id=1&x=foo" or null

  // It can be modified like this (assuming AUTH_TOKEN is defined eslewhere) =
    (( ? + "&" : "") +
    "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);

Using strings for concatenation can lead to a runtime complexity on the order of O(n^2).

If you use a StringBuilder, there is a lot less copying of memory that has to be done. With the StringBuilder(int capacity) you can increase performance if you can estimate how large the final String is going to be. Even if you're not precise, you'll probably only have to grow the capacity of StringBuilder a couple of times which can help performance also.

By : Steve g

Video about In JQuery, using ajaxSend to preview the url built by $.post call