Click here to Skip to main content
11,416,787 members (54,222 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: PHP Ajax
$("cApplication'.$col1.'").click(function(){
				$.ajax({
					url: "?page=acp_apps_check",
					type: "post",
					data: {capp:'.$col1.'},
					success: function(){
						alert("set session");
					}
				});
			)};

The following Ajax code leaves this error for no reason:
Uncaught RefernceError: $ is not defined

Can't understand the problem.

Full PHP code:
echo '<head><script src="jquery.js"></script>
			<script type="text/javascript">
			$("cApplication'.$col1.'").click(function(){
				$.ajax({
					url: "?page=acp_apps_check",
					type: "post",
					data: {capp:'.$col1.'},
					success: function(){
						alert("set session");
					}
				});
			});
			</script>
			</html></head>';
Posted 9-May-13 9:36am
Edited 9-May-13 9:38am
v2
Comments
ryanb31 at 9-May-13 14:39pm
   
Do you really mean to send the string value ".$col1."? Also, the last combination of squiggs and parens is wrong. It should be just like the closing of the .ajax function }); Just follow their order.
NextGenDeveloper at 9-May-13 14:43pm
   
Yes I do, I'm doing something that runs on a loop so I need it to work this way.

Also I updated the error, I posted the wrong one. I know that they were not in the right order.
ryanb31 at 9-May-13 14:44pm
   
$ is not defined means the browser does not know what $ is. You need to load jquery.js.
NextGenDeveloper at 9-May-13 14:48pm
   
Thanks! all of the errors are gone, kinda forgot that there is a jquery.js that you need to download and put.
ryanb31 at 9-May-13 15:08pm
   
Glad to hear.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

$ is not defined means the browser does not know what $ is. You need to load jquery.js.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,295
1 OriginalGriff 7,592
2 Maciej Los 3,718
3 Abhinav S 3,456
4 Peter Leow 3,084


Advertise | Privacy | Mobile
Web04 | 2.8.150427.4 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100