[jQuery] $ajax does not send all data

2009-05-10 Thread Tim Johnson

The following function is used as the onsubmit handler for a form:
// 
---
function checkCPForm1(theform) {
  if(ValidateCPForm(theform)){
var data = $(theform).serialize();
alert(data:  + data);  // DEBUG GLOBAL
$.ajax({
  type: theform.method, 
  url: theform.action,
  data: $(theform).serialize(),
  datatype: 'html',
  success: function(html){$('#dynamic_content').html(html)},
  error: function(XMLHttpRequest,textStatus,error){
alert(ERROR:\n + textStatus, + \n + error)
}
  }); 
  return false;
} else return false;
  }
// 
-
Not all the form data is included in the data string.
What _is_ missing is 
1)the name and value for the submit button itself.
In traditional CGI programming, I've found that names and values for
submit buttons are always sent. And I've gotten used to strategies
where more than one submit button is included in a form
2)The name and value for a radio button _when_ the button is named
'someType' as in 'licenseType'. If the name is changed to say, 'license_type',
data is transmitted as expected.

I've encountered this problem with another ajax library, so I don't think this
is particular to jquery.  

Any comments are welcome. Pointers to relevant documents, RFCs,
dicussions welcome as well.
thanks
tim 


[jQuery] image for public usage

2009-05-04 Thread Tim Johnson

Since jQuery is one of my tools - I'd like an appropriately
public image to use on my website.

Are any available?
thanks
tim


[jQuery] Re: image for public usage

2009-05-04 Thread Tim Johnson

On Monday 04 May 2009, Sam Sherlock wrote:
 http://docs.jquery.com/Design_and_Identity

Thanks a lot! Does the trick..
 tj


[jQuery] Re: Recommend tree widget toolkit

2009-03-12 Thread Tim Johnson

On Wednesday 11 March 2009, jQuery Lover wrote:
 I have not tested nor worked with lots of tree widgets, but treeView
 is a lightweight and robust plugin...

 http://be.twixt.us/jquery/treeView.php

 thanks, I will check that out. BTW: dojo did come thru with the
addition code needed, but what a lot of resource loading!
Cheers
tim


[jQuery] Recommend tree widget toolkit

2009-03-11 Thread Tim Johnson

Hello:
If jquery itself does not support a tree widget toolkit,
can anyone recommend one, I've tried dojo but
two problems:
1)doesn't work - even verbatim example
2)No support
3)Very big system

Any comments or  recommendation welcome.
thanks
tim


[jQuery] Re: Javascript Generated by $()load does not render

2009-02-18 Thread Tim Johnson

On Tuesday 17 February 2009, Alexandre Plennevaux wrote:
 i suppose that you change try specifying the dataType as script that
 your ajax calls expect:

 Taken from: http://docs.jquery.com/Ajax/jQuery.ajax

 dataType

 The type of data that you're expecting back from the server. If none
 is specified, jQuery will intelligently pass either responseXML or
 responseText to your success callback, based on the MIME type of the
 response. The available types (and the result passed as the first
 argument to your success callback) are:
 Thank you. That clears up a lot. But the question that remains is that
 two different types of data are returned:
 1)Script
 2)Text
 The answer may be in the mime type. $()load is so much easier to use.
 I will research futher.
 regards
 tim




[jQuery] Re: Javascript Generated by $()load does not render

2009-02-18 Thread Tim Johnson

On Wednesday 18 February 2009, Alexandre Plennevaux wrote:
 you can use load, you just have to setup the ajaxSetup controlling
 your ajax main parameters so you set it to your liking, then you call
 the load(). It is built on top of the ajax method to ease its use.
 See: http://docs.jquery.com/Ajax/jQuery.ajaxSetup#options
  I am looking at: http://docs.jquery.com/Types#Options
  in addition I am looking at printed material
  I see from the book: jQuery In Action - page 252 documentation for
 $.ajaxSetup(properties). The properties object can contain a dataType value.
 
 1)What datatype value would configure $load so that it would handle
 both script and html. IOWS the CGI script returns both javascript 
 and html?

 2)Are these datatype strings themselves case sensitive.
  
  Time is limited for me right now, I'll do my home work a little
  later. :-)
  
 thanks again


[jQuery] serializing data from a jquery-rendered form

2009-02-18 Thread Tim Johnson

The goal is a multi-stage process schema where a form is rendered
by a cgi script and inserted into a static web page via this method:
[code]
  $(document).ready(function(){ 
  var myscript;
  if(document.domain == 'bart.johnson.com') // local
myscript = http://bart.johnson.com/cgi-bin/woods/phhDonate.r;;
  else
myscript = http://www.somedomain/cgi-bin/script.r;;
$(#dynamic_content).load(myscript,task=entry,
function(resp,stat,xhr){
//alert(resp);  // leave for testing
}) });
[/code] And is successful.
The second stage is to validate the input form that is rendered by the
method above and write out a review form to the 'dynamic_content'
innerHTML. The form provides an 'onsubmit' handler, called as follows
from the form tag: onsubmit=return CheckForm0(this);
coded as follows:
[code]
  function CheckForm0(myform){ // myform is the 'this' in CheckForm0(this);
if(Check_Form0(myform)){ // validation code
  $(#dynamic_content).load(myform.action,$(this).serialize(),
function(resp,stat,xhr){
//alert(resp);  // leave for testing
}
);
  return false;
  }
return false;
} //[/code]

The problem is that $(this).serialize does not provide the encoded
string that the CGI script is looking for. Does jQuery provide a function
to serialize the 'myform' argument?

thanks
tim




[jQuery] Re: Javascript Generated by $()load does not render

2009-02-18 Thread Tim Johnson

On Wednesday 18 February 2009, Alexandre Plennevaux wrote:
 see if this resolves your issue:
 Hi Alexandre:

 Thanks very much for your help on this issue, but it still
 does not work.

 However, I already have a workaround to enable functionality - and in the 
 future - a different approach could be tried.

 In the meantime, :-( I'm stymied on another issue - 
 see subject: serializing data from a jquery-rendered form
 Keep up your good work!
 Tim

 ...

  $(document).ready(function(){
  $.ajaxSetup( {
 dataType: 'script'
 }) ;

$(#dynamic_content).load(myscript,task=entry,
function(resp,stat,xhr){
//alert(resp);  // leave for testing
}
);
  });

 


[jQuery] Re: serializing data from a jquery-rendered form

2009-02-18 Thread Tim Johnson

On Wednesday 18 February 2009, Tim Johnson wrote:
 The goal is a multi-stage process schema where a form is rendered
 by a cgi script and inserted into a static web page via this method:
 
 The second stage is to validate the input form that is rendered by the
 method above and write out a review form to the 'dynamic_content'
 innerHTML. The form provides an 'onsubmit' handler, called as follows
 from the form tag: onsubmit=return CheckForm0(this);
 I've changed the code to this:
  function CheckForm0(form){
if(Check_Form0(form)){
  var data = $(Form0).serialize();
  alert('data: ' + data);
  $(#dynamic_content).load(form.action,$('Form0').serialize(),
function(resp,stat,xhr){
alert(resp);  // leave for testing
alert(stat);
}
);
  return false;
  }
I can verify that Check_Form0 // the validator
is working. However, even tho the form has at least a dozen
items filled in, the alert() call is an empty string.  The response
string indicates that the CGI script has not received any data,
yet 'stat' is success.
---
tj



[jQuery] Javascript Generated by $()load does not render

2009-02-17 Thread Tim Johnson

I have a script that generates javascript validation code when called 
in the following code:
  $(document).ready(function(){ 
$(#dynamic_content).load(myscript,task=entry,
function(resp,stat,xhr){
//alert(resp);  // leave for testing
}
);
  });
All of the contented rendered by 'myscript' is written to the innerHtml of 
div dynamic_content *except for the javascript*.

I am viewing the content rendered by the script in firefox using the 
View Formatted Source add-on.

 If I uncomment the alert() above, I see the javascript in the response.

Does anyone have an answer for this mystery. Or a work-around. Any links
to discussions on this topic? 

thanks
Tim


[jQuery] Re: jQuery Plugin Hello World

2009-02-16 Thread Tim Johnson

On Sunday 15 February 2009, mtsmit2 wrote:
 The following is a pretty good starting point.

 http://docs.jquery.com/Plugins/Authoring
 What is was looking for you.
 thank you
 tim


[jQuery] jQuery Plugin Hello World

2009-02-15 Thread Tim Johnson

Google gives me lots of hits on jQuery Plugin

However, I have yet to find a _very_ simple example.
One that would demonstrate the simplest syntax and
also demonstrate where to install the file with the
plugin..

Links are welcome. I'll take it from there.
thanks
Tim


[jQuery] Generate Session ID

2009-02-14 Thread Tim Johnson

I'm transitioning from old-style CGI programming to using
jQuery to access the server via Ajax. It is customary for me
to have the CGI script generate a random string to use as
a session ID. 

Using Ajax with jQuery - would it be practical and safe for the
document to generate a Session ID in the onload or document.ready
phase and pass it to the server-side script?

Comments, caveats and examples are welcome.
thanks
tim


[jQuery] Re: Generate Session ID

2009-02-14 Thread Tim Johnson

On Saturday 14 February 2009, C.Everson wrote:
 On Sat, 14 Feb 2009 10:41:05 -0900, Tim Johnson wrote:
  Using Ajax with jQuery - would it be practical and safe for the
  document to generate a Session ID in the onload or document.ready
  phase and pass it to the server-side script?

 Tim,

 IMHO the ONLY way to ensure a unique session ID is to generate it server
 side.

 Otherwise no matter what you do (client side) there is a chance of
 duplication.
  Understood. I'll stick with my tried-and-true cgi methods.
  thanks
  tim


[jQuery] Re: Status Codes = docs

2009-02-12 Thread Tim Johnson

On Wednesday 11 February 2009, Nic Luciano wrote:
 http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

 Something like this?

 I might be misunderstanding your question, but I don't think statuses and
 datatypes are related if that's what you mean. Status codes (linked) are
 the status of the call.. (ie. a return status of 200 means everything went
 OK). Data type is the format of the data you are expecting to return (html
 for plain html to insert into your document, json for js objects, etc)...
 Sorry.
 To clarify, I wanted ed to know if numerical statuses via the w3 protocol
 or text strings were being returned. I just did my first successful ajax
 call using jquery and the status returned in the callback was success, not 
200.

 I hope the question is clearer now.
 thanks
 tim


[jQuery] Re: Status Codes = docs

2009-02-12 Thread Tim Johnson

On Thursday 12 February 2009, Mike Alsup wrote:
  Textual status is fine.
  Where is documentation on status strings?
  Thanks
  Tim

 When the 'success' handler is invoked the textual status is always
 success (unless you're using the ifModified option).

 When the 'error' handler is invoked the textual status may be error,
 parsererror, or timeout.

 When the 'complete' handler is invoked the textual status may be any
 of those mentioned above.

 Both the 'complete' and 'error' callbacks are passed the XHR as the
 first arg.  With that object you can determine the HTTP status via its
 'status' property.
Understood. Thanks.
 I couldn't find a wiki page that succinctly covers this so I'll make a
 note to add one.
 Good idea.
 regards
 tim




[jQuery] Re: $.post NOT_ENOUGH_ARGS

2009-02-11 Thread Tim Johnson

On Tuesday 10 February 2009, mkmanning wrote:
 For the second argument use $(form).serialize()

 You should also use onsubmit=return CheckForm0(this);
 although the best practice would be to remove the inline script and
 bind
 the submit event like this:
  $('form').submit(function(){
  //do your ajax here and return false
 });
  But what would bind the form in your example? I frequently
  work with multiple forms. I.E. is 'form' in your $.submit()
  above the name or ID of the form or is it an object from which
  name or ID could be extracted as a property.
  Thanks
  Tim


[jQuery] Re: $.post NOT_ENOUGH_ARGS

2009-02-11 Thread Tim Johnson

Thank you very much James.
this is great!
cheers
tim

On Wednesday 11 February 2009, James wrote:
 You can use a generic classname on all your forms.

 form action=process1.php id=form1 class=myForm
 ...
 /form

 form action=process2.php id=form2 class=myForm
 ...
 /form

 $(function() {
  $(.myForm).submit(function(){
   $.post($(this).attr(action),
$(this).serialize(),
function(response,mystatus) {
 alert('response: ' + response +  status:  +
 status);
});
return false;
   }
  });
 });

 


[jQuery] Status Codes = docs

2009-02-11 Thread Tim Johnson

I would be grateful if someone could point me to documentation
on status codes.

Example: $post() expects a callback function whose second argument
would be status. 
What statuses should I expect and what datatype for statuses
should I expect.
Links to docs would be more than adequate.

_Thanks In Advance_ and thanks for all the help I've had so far.
tim


[jQuery] $.post NOT_ENOUGH_ARGS

2009-02-10 Thread Tim Johnson

My source is jQuery in Action (Bibeault/Katz) - page 249,
the $.post function.
According to the documentation post() takes three arguments:
URL, parameters, callback where callback is a function with 2 arguments,
response and status.
I've tried the following - which is called from the form
as onsubmit=CheckForm0(this); [code]
// argument 'form' is the reference to entry form
function CheckForm0(form) {
$.post(form.action,form,
  function(response,mystatus){
alert('response: ' + response +  status:  + status);
})
  return false;
  } [/code]
But I get the following error message:

Error: uncaught exception: [Exception... Not enough arguments  
nsresult: 0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)  location: JS frame :: 
http://bart.johnson.com/js/jq/jquery.js :: anonymous :: line 3636  data: no]

Am I correct that the callback function needs another argument?
It would be helpful if someone could point me to what I have done
incorrectly.

Thanks
Tim (not an ajax virgin, but a jQuery noob)


[jQuery] Re: $.post NOT_ENOUGH_ARGS

2009-02-10 Thread Tim Johnson

On Tuesday 10 February 2009, James wrote:
 The second parameter (where you have 'form') is suppose to be a JS
 object like:
 {name:form.myName, email:form.email, phone:form.phone}
 Potentially, 'form' could have hundreds of elements and in
 reality, does. So how to convert the 'form' object into a JS
 object? I've worked with another framework that does that
 'auto-magically'. Could you refer me to an example of how to
 do that? And I will research it as well :-) not asking you to do
 my homework for me.
 thanks
 tim




[jQuery] Convert from AjaxRequest to jQuery/ajax

2009-02-08 Thread Tim Johnson

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



[jQuery] Re: Convert from AjaxRequest to jQuery/ajax

2009-02-08 Thread Tim Johnson

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




[jQuery] Re: Convert from AjaxRequest to jQuery/ajax

2009-02-08 Thread Tim Johnson

On Sunday 08 February 2009, pedalpete wrote:
 Sorry Tim, I didn't understand it that way.
 :-)
 You should still be able to do this fairly simply.
 Looks like I will also have to use a wrapper to get the form
 using the 'this' keyword, since I work with multiple forms.
 I think I can get what I need by something like this:
 Illustrated by:
   function CheckForm(f) { // triggered by onsubmit=CheckForm(this);
 var formname = f.name;
 var url = f.action;
 var meth = f.method;
 // illustrated by
 alert('Action: ' + f.action + '\nMethod ' + f.method + \nName:  +
   f.name);
 // I'll review your examples, this gives me a start
 // more code ..
  return false;
  }
  //Thanks
  //tim
 You don't have to specify the url, you can pass it as a variable.
 But you would need to put your $.ajax function into another function,
 and call it when clicked. You can also build the data variables in the
 other functions.

 For instance
 [code]
 $('form#1').submit(function(){
var url=$('form#1).attr('action');
// then get your data variables and do whatever you want to do with
 them
 var type= get;
 submitForm(url, data);

 });

 function submitForm(url, data){
 $.ajax({
  type: type,
  url: url,
  data: data,
   success: function(){

 }
 })

 }

 [/code]

 I hope that helps, and that I understand what you were trying to do
 better than my first answer.




[jQuery] Writing Ajax to table cells.

2009-02-05 Thread Tim Johnson

FYI: I am an experienced web programmer (server-side mostly)
with some exposure to javascript and have used ajax calls
and dhtml methods a little.
Furthermore - I do not _yet_ use jquery. 
This question is to - some extent - being asked of behalf
of a web designer who himself is not on this ML.

The designer wants his design to accomodate ajax calls which
would retrieve data via my server-side tools and write the data
to his pages.

The web designer is accustomed to working with tables. It has
been our understanding that ajax and dhtml don't play well with
tables, thus he has gone to considerable effort and much frustration in 
creating a couple of test pages using div tags only - no tables, but remarks
that this has been very labor intensive. 

So his (and my question) is: Is it possible and practical to use jquery
ajax calls to write to tables?
What idioms might be necessary? Since this is a general question,
links to discussions or documents are welcome and may be sufficient.
Furthermore, caveats and warning are welcomed also.
thanks
tim


[jQuery] Re: Writing Ajax to table cells.

2009-02-05 Thread Tim Johnson

On Thursday 05 February 2009, David Meiser wrote:
 I'm not 100% sure what you're trying to accomplish, but you can output
 anywhere on the page using a distinct element name.

 I have code in which I attach tables generated in jquery to DIVs, for
 example.  And I'm certain you could go the opposite way, as well.

 Hope that helps, somewhat.
  My suggestion to him was consider div or span tags inside of td elements.
  I'm probably a bit ahead of myself - I should try a test with jquery writing
  to such a tag inside of a table cell - - -
thanks for the reply
tim