Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!

Dennis Spring

Greenhorn
+ Follow
since Apr 07, 2010
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dennis Spring

I think I understand your point about the low barrier to entry re: php.
It's true that some serious spaghetti(non-edible) can be produced in that environment.
But, if you have the discipline to use good OO practises, a framework, and use-case-modeling,
I think you can turn out a good product.

I found limited employment opportunities in the Charlotte area with Java, and my path has led me
to the point where I am. I am still at a point in my life where I need to earn money.
That's what I was asking when I inquired what led you to Java - not the previous languages you
worked with, but rather where did you find the employment/project opportunities?

Most of my work for my current employer has been related to an interface between apps via
apache->php->xml.
I will soon be working with a team on an admin site, that, for various reasons, will have
all the 'bells and whistles' of an RIA. Hence, the need to learn jQuery.

Regarding your Chapter 8 example code:
I downloaded the compressed file from manning/bibeault2, as you recommended, but there don't
seem to be any php files available.
I have slightly modified your page boot.closet.2.html to work with 2 new pages: getColors2f.php and
getSizes2.php. It retains the original intent of demonstrating the use of the jQuery Fn $.getJSON()
and the dependant 'drop-downs'.
I would be happy to attach them to an email, or can copy and paste to a forum at this site, if you
let me know which one.
Regards, Dennis
Can the blurring effect be used to facilitate the impression of motion?

Any requests?


How about an image implying the movement of a fiddle player's bow-arm?



9 years ago
The company I work for decided a couple of years ago to use Apache.
I will be building some forms in the near future, using jQuery, so I'm learning it now.

Just curious:
How did you get started with Java? as opposed to another language?

I have been looking at the manning site - I don't see a different download for second edition.
Do I need to order the eBook version of 2nd Edition to get that?
I don't have an eBook device.

regards,
Thank you, sir.
Yes. Pointing my browser to:
http://localhost/jqman/jqia.source/chapter8/bootcloset/getColors.php?style=7141832

produces this response:
<option value="">choose color</option>
<option value="bk">Black</option>
<option value="br">Brown</option>

which is legit markup for the correct case(style=7141832), but it does not look like what I would expect
for a json_encoded string.
If .getJSON() is expecting a JSON formatted string, this would be a problem, right?

BTW:
Thanks for mentioning, the other day, that you had no issue 'seeing' the ajax page at jQuery.com
I pulled out my old (Windows)laptop and hit the jQuery.com website with it. No Problem!
There is must be something in the Ubuntu version of Firefox that does not like the pages at jquery.com.
First time I've seen any issue with this desktop station running Firefox.

Anyway:
At the jQuery.com site, their example for the data page looks similar to this:

{
"style" : "<option value=''>choose color</option>"
}

So, of course, I made such a page and called it in the ajax Fn. Result:
Alert Ln: 41: [object Object]
which indicates that some kind of an object is being returned.
Is it possible the Fn .loadSelect(), referencing the included 'jquery.jqia.selects.js',
is not designed to handle the string as formatted above?

Since I am not a Java dude, I will try creating a small jQuery .each() Fn that treats this object as an
array and see what happens.

Again, thanks for your help.
Dennis
I am struggling with the boot.closet.2 exercise/example.
I get no errors, yet I get no response from the ajax calls.
Neither a .getJSON call to getColors.jsp, nor a call to getColors.php returns
any data. No errors detected by Firebug - but no data.
And no data means that html is not being set in the html page's 'colorDropdown' select element.

There are several pages involved, and I would like to know if it is appropriate for me to post all that code
here, or do I assume that once I reference the book, whoever replies has that code at his/her
disposal?

On the off-chance that the assumption is true:
in boot.closet.2.html
inside function adjustColorDropdown():
The alert box at (my) line 36 gets produced.
The alert box at (my) line 41 does not get produced.

(ps; Since I am running this thru the Apache mill, php is my preferred language for a data page.)
(pps; the code I am running came from the Manning Publishing website. 'loadSelect' is a js Fn
in an included file. )

thanks.
Dennis
Ouch. I have rarely been accused of not being forthright...
I did not post the question to another site.
One of the 'young guns' at our company helped me with it on his break.
I have shared that info with the folks visiting your site.

I did originally post the question to the 'Web' forum on your site.
However, someone moved it from that forum to something called the backporch forum, or something...
I re-posted it on this HTML forum, after I found it, hoping to get a response.
Apparently it was moved a second time to this forum, after I posted it here.

Seems like a lot of anger for a friendly place...
I did, after all, provide code for a php alternative('getDetails.php') for chapter 8 of Mr. Bibeault's book 'jquery in Action'.



Solution:

jQuery.load() expects the second parameter to be a hash.
(kudos to Brandon Orther)
I am having difficulty getting the .load() method to work with a POST variable parameter.
I searched the founders' site, jQuery.com, but there is an issue on their web-page dealing with the .load()
method for ajax calls. The issue prevents the page from fully loading. In other words, I cannot get
access to the information I need.

In my previous post to this javaRanch site,
"jQuery In Action Chapter 8 - use a php data file for ajax call" on April 14,
I detailed the GET method which works just fine, and the POST which does not.

I suspect the GET method is less secure, and besides, the spec for the project I'm doing
defines that POST vars are to be used.

Can anyone help me out?

regards,
Dennis
For those not addicted to TV, here is my favorite book of the last 2 years.
'Faith, Madness, and Spontaneous Human Combustion' by Callahan is an amazing look at what we are made of.

Dr. Callahan is a doctor of immunology, and a philosopher. His book is a 50 - 50 dose of each.
The premise of the book is that our immune system - more than our brain, more than our nervous system, more than anything else - is what defines who/what we are.

I have never before read a biology-related book that I could even REMOTELY call 'fascinating', but I found this one to be so.
I actually bought 6 more copies and gave them to my best friends.

Disclaimer 1: the first chapter is arguably the weakest chapter of the book. Keep reading!
Disclaimer 2: the book does not deal that much with Spontaneous Human Combustion(1 chapter). But it sure makes for a great book title!

regards,
Dennis



9 years ago
I am having difficulty getting the .load() method to work with a POST variable parameter.
I searched the founders' site, jQuery.com, but there is an issue on their web-page dealing with the .load()
method for ajax calls. The issue prevents the page from fully loading. In other words, I cannot get
access to the information I need.

In my previous post to this site,
"jQuery In Action Chapter 8 - use a php data file for ajax call" on April 14,
I detailed the GET method which works just fine, and the POST which does not.

I suspect the GET method is less secure, and besides, the spec for the project I'm doing
defines that POST vars are to be used.

Can anyone help me out?

regards,
Dennis
jQuery In Action:
Re: Chapter 8
I could not get the POST var syntax to work for the script calling the data file with the .load() method.

You can use a php page for the data file, in place of the getDetails.jsp.
The code for my version of getDetails.php is :



******************************************************
remember to use echo - not return!
******************************************************

The calling page, boot.closet.1.html, needs a mod in the javascript:

This call, using GET var syntax in the 7th line works:


- - - - - - - - - - - - - - - - - - - - - - - - - - -

This call, using POST var syntax, does NOT work.
(Maybe someone can enlighten me.)



The web page for the .load() method at jQuery.com has a glitch. I need another good lead on where I have gone wrong with the POST var syntax. Anyone have an idea?
9 years ago
How do you determine if there are any checkboxes in an html form that are checked?
You can copy these 2 scripts into2 files, and try this solution.
Note: The html script assumes that you have jquery-1.2.1.js and ds_jq.js in a folder
up one level called 'scripts'. You can un-rem the alert on the js page to confirm that
the html page 'sees' the js page.


The code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- ckbox_testpage.html -->
<!-- Dennis Spring, Charlotte, NC USA 2010-04-07 -->
<html>
<head>
<script type="text/javascript" src="../scripts/jquery-1.2.1.js"></script>
<script type="text/javascript" src="../scripts/ds_jq.js"></script>
<script type="text/javascript">
$(function(){
$(':checkbox').click(function(){
// if the wrapped set has any elements in it...
if ($('input:checkbox:checked').length > 0){
// do some work...
alert("head-script: There is a Checked checkbox.");
}
});
});
</script>
</head>
<body>
<div id="formDiv">
<form action="another_page.html" method="POST" id="frm1">
I like dogs: <input type="checkbox" name="likeDogs" value="likes dogs"/>
I like cats: <input type="checkbox" name="likeCats" value="likes cats"/><br/>
</form>
</div>
</body>
</html>
********************************

// ds_jq.js
// Dennis Spring, Charlotte, NC USA 2010-04-07

jQuery(document).ready(function() {

//alert("ds_jq.js found!");

if ($('input:checkbox:checked').length > 0) {
// do some work...
alert("js include: There is a Checked checkbox.");
}

});

Issue:
I first tried the following syntax to determine if there existed a checked checkbox:
if ($('input:checkbox:checked')) alert("There is a Checked checkbox.");
But even when no box was checked, the decision tested true, and the Alert window popped up.

Sheriff Bibeault enlightened me with this explanation:
"
Your if test will always return true. The $() function is returning a jQuery wrapped set, even if
that wrapped set is empty.
Make your test more crisp and explicit:
if ($('input:checkbox:checked').length > 0)
"

Using that code does the trick. Try it.
Load the page into your browser (your url might be something like http://localhost/htdocs/ckbox_test_page.html).
Note that no js Alert window popped up. Neither checkbox was checked, so this was expected.
Click in a checkbox. The Alert window indicates that the click handler in the head of the html page executed.
Next, click the Refresh button on your browser; the Alert window indicates that the ready handler script in ds_jq.js fired.
Click the other checkbox: again the local function executes.
Finally, click one of the checkboxes again, un-checking it.
Note that the html page javascript fires again, because there is still one checkbox checked.
9 years ago