Page 1 of 1

PHP/Jquery conflict?

Posted: Sun Dec 11, 2011 3:24 pm
by jemagee
I have a page that makes heavy use of Jquery and the Jquery UI. It works exactly as I wish it to with a .html extension. If I switch the extension to .php, even before adding any php code, the page no longer loads properly on my server.

Has anyone run into this before? Is there someone with php and jquery skills who might take a look at the code and see if there's a glaring error i'm missing?

THanks in advance

Re: PHP/Jquery conflict?

Posted: Sun Dec 11, 2011 4:01 pm
by twinedev
Can you post the code here?

Re: PHP/Jquery conflict?

Posted: Sun Dec 11, 2011 4:08 pm
by jemagee
It's posted below.

I realize that it's not the most elegant or clean code in the world, but I'm still working on figuring out how to plan my pages, for me the building itself is a big deal. It does function the way I want it to with the html tag, but I want to add some PHP checking. I need to be able to check if the user is logged in AND if they already submitted their picks. I could do that on the 'submission' processing but i'd rather do it on this page if possible. I expect there's something minor i don't see.

Thanks in advance for taking the time to even look at it.

Code: Select all

<script>
	$(function() {
		var lockcount=0;
		$(".invisible").attr("value","");
		$("ol.pick").sortable();
		function checkSubmit($count) {
			if($count==6) {
			$("#submitpicks").removeAttr("disabled");
			} else {
			$("#submitpicks").attr("disabled","disabled");
			}
		}
		$("p.lock input").click(function() {
				var status=$(this).attr("locked");
				var division=$(this).attr("division");
				var lockstatus=$(".lockStatus."+division);
				if (status=="on") {
					//turn on sorting
					$("#"+division).sortable("option", "disabled", false);
					//clear input fields
					$("input."+division).attr("value","");
					//remove locked notification
					$(this).attr("locked", "off");
					$(this).attr("value","Lock");
					lockstatus.text("Unlocked");
					lockcount --;
					checkSubmit(lockcount);
				} else {
					//turn off sorting
					$("#"+division).sortable("option", "disabled", true);
					//populate input fields
						for (i=1; i<=5; i++) {
							j=i+1;
							pick=$("#"+division+" li:nth-child("+j+")").attr("id");
							$("#"+division+i).attr("value",pick);
							}
						
					//visible locked notification
					$(this).attr("locked", "on");
					$(this).attr("value","Unlock");
					lockstatus.text("Locked");
					lockcount ++;
					checkSubmit(lockcount);
				}
		});
	});
	</script>

Re: PHP/Jquery conflict?

Posted: Mon Dec 12, 2011 10:34 am
by pickle
Do you get any Javascript errors? Is this an HTML5 page or some variant of xhtml? If the latter, you might need to modify your <script> tags to [text]<script type = "text/javascript">[/text]

Re: PHP/Jquery conflict?

Posted: Mon Dec 12, 2011 10:39 am
by jemagee
NOt using HTML5

No javascript errors when I run the page with HTML extension - everything functions perfectly
I'll try the script type issue tonight (when I get home) but I have another page (simpler code, just really error checking on forms) that is also jQuery with the .php tag, and the jQuery is between <script></script> without the declaration.

Then again, last night I discovered that if you have an 'include' for your database connection and want do do a loop of six inserts - it won't work unless the include is part of the loop - which doesn't make sense to me - but it is what it is :)

Re: PHP/Jquery conflict?

Posted: Mon Dec 12, 2011 10:51 am
by pickle
Also, post the entire content of the page, as it gets sent to the browser (View Source).

Re: PHP/Jquery conflict?

Posted: Mon Dec 12, 2011 10:54 am
by jemagee
For the working page or the error page? The error page doesn't post anything - a white page

The working page is here http://www.johnhasadhd.com/basketball/picks.html

Re: PHP/Jquery conflict?

Posted: Mon Dec 12, 2011 11:00 am
by pickle
If it's all white, there's a chance PHP isn't enabled on your account. Do you have other .php files working? If it is enabled, turn on error reporting. A blank white page usually means a fatal error happened but PHP isn't set up to display errors.

Re: PHP/Jquery conflict?

Posted: Mon Dec 12, 2011 11:05 am
by jemagee
Yes I have PHP Enabled on both servers at home and at the web site

PHP works fine on all other files - it's this one specific file - change the extension and everything stops working

I do need to turn on error checking on my home server (Max OS X Apache PHP)