tags:

views:

1870

answers:

2

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?..so 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:

http://myServer/cgi-bin/broker?service=myService&program=myProgram&section=mySection&start=09/08/08&end=09/26/08

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

$(function() {
 $("#submit").bind("click",
  function() {
   $.post({
     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") ;
      $("#updateHTML").html(request.statusText);
      },
     success: function(request) {
      $("#updateHTML").removeClass("hide") ;
      $("#updateHTML").html(request) ;
      }
    }); // End post method
   }); // End bind method
  }); // End eventlistener

Thanks

+1  A: 

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.

yes, that is what I'm after
CarolinaJay65
thanks, firebug helped me make sure I was sending a proper url to the server
CarolinaJay65
+1  A: 

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) {
  // settings.data is either a query string like "id=1&x=foo" or null

  // It can be modified like this (assuming AUTH_TOKEN is defined eslewhere)
  settings.data =
    ((settings.data) ? settings.data + "&" : "") +
    "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
});
Jonathan Tran