Click here to Skip to main content
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 OriginalGriff 230
1 PIEBALDconsult 150
2 DamithSL 125
3 Andreas Gieriet 90
4 Jochen Arndt 90
0 OriginalGriff 5,790
1 DamithSL 4,601
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,195


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2014
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