On Sunday 08 February 2009, pedalpete wrote:
> I believe the code you are looking for would be something like this
Hi pedalpete:
Thanks you for the quick response.
> [code]
> $('form').submit(function(){
> var cell1 = $('#cell1').html();
> var div1= $('#div1").html();
> var span1=$('#span1").html();
> $.ajax({
>          type: "GET",
>          url : 'urlToGet.php',
>          data: 'cell1='+cell1+'&div1='+div1+'&span1='+span1,
>          success: function(response){
>                  // whatever you want to do with the response
> }
> });
As you see, the type and url are "hard coded" into the function.
Furthermore, if I understand the interface to the function, 'form'
as also "hardcoded"

In the case of the example that I submitted, the form is passed
as the 'this' keyword, allowing this function to have more than one caller.
Thanks again, more examples are welcome, but perhaps I would have
to dig deep and learn to write a wrapper.

cheers
tim
> });
> [/code]
>
> On Feb 8, 4:23 pm, Tim Johnson <t...@johnsons-web.com> wrote:
> > For some time I've been using a little ajax library called AjaxRequest.
> > Because I'm working with code generation tools, I'd like to make a
> > first - step switch to jQuery as simple as possible.
> > A sample AjaxRequest function follows:
> >   function CheckForm0(theform) {
> >         AjaxRequest.submit(
> >           theform
> >         ,{
> >           'onSuccess':function(req){
> >                var res = req.responseText.split('\n')
> >                document.getElementById("cell1").innerHTML = res[1];
> >                document.getElementById("div1").innerHTML = res[2];
> >                document.getElementById("span1").innerHTML = res[3];
> >                alert(res[0]);
> >                },
> >           'onError':function(req){ alert("ERROR: " + req.statusText);}
> >           }
> >         );
> >         return false;
> >   } // end function
> > // Form tag follows:
> > <form method="post"
> > action="http://bart.johnson.com/cgi-bin/baker/reb/test-ajax.r";
> > onsubmit="return CheckForm0(this);">
> > // Note that method, action, and onsubmit parameters are in the tag
> > // and I would prefer that they remain there. Also the form is referenced
> > // by 'this' in the onsubmit parameter and passed to the Ajax function.
> >
> > I'd appreciate pointers to jQuery examples that would help me with the
> > transition. I'd like an approach that requires as few changes to the form
> > tag as possible.
> >
> > Thanks
> > Tim


Reply via email to