Click here to Skip to main content
12,078,761 members (48,594 online)
Rate this:
 
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 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 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 9-May-13 14:44pm
   
$ is not defined means the browser does not know what $ is. You need to load jquery.js.
NextGenDeveloper 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 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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web03 | 2.8.160212.1 | Last Updated 9 May 2013
Copyright © CodeProject, 1999-2016
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