We help IT Professionals succeed at work.
Get Started

PHP AJAX Issue

Robert Granlund
on
116 Views
Last Modified: 2015-10-30
I have an AJAX call that I believe is put together correctly.  However, when I run it, there are no returns.  Even though the query should return entry ID's.  Can anyone just have a quick look and let me know their thoughts where I am going wrong?

<html>
		<form action="#" method="get" id="laser_finder">
  <!--  Operating Mode  -->
  	<div class="form-control main title">
  		Operating Mode
  	</div>
 <!--  START CW  -->
  	<div class="form-control">
  			<input type="checkbox" name="cw" class="laser_operating_mode"  id="cw" value="CW (Continuous Wave)" >
  			<label for="cw">
  				CW (Continuous Wave)
  		</label>
  	</div>
<!--  START Pulsed  -->
  	<div class="form-control">
  				<input type="checkbox" class="laser_operating_mode" name="pulsed" id="pulsed" value="Pulsed" >
  				<label for="pulsed">
  				Pulsed
  		</label>
  	</div>

Open in new window

The jQuery
<script>
$(document).ready(function(){
$( ".laser_operating_mode" ).change(function (e) {
e.preventDefault();
function laser_finder() {
	$.ajax({
		type: 'GET',
				url: '{site_url}/ajax/laser_finder.php',
				data: {action:"laser_finder"},
				dataType: 'json',
				success:function(data) {$('#results').html(data);}
			});
		}
  			laser_finder();
		});
	});
</script>

Open in new window


The PHP
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

$action=$_GET["action"];
	if($action=="laser_finder") {
		
		$cw = $_GET['cw'];
		$pulsed = $_GET['pulsed'];
		
		$laser_query = ee()->db->select('entry_id')
		->from('exp_matrix_data');
		->where('col_id_6401', $cw)
		->where('col_id_6401', $pulsed)
		->get();
		
		
		foreach($laser_query->result_array() as $row){
   			echo $row['entry_id'];
   		}
	}  
?>

Open in new window

Comment
Watch Question
Freelancer
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE