I am new to cakephp and trying to implement ajax in it. my controller photographers function api_search is:
/*resides in photographers_controller.php*/
function api_search() {
return 'Demo';
}
And the search.ctp is :
<script>
$(document).ready(function() {
get_search_results();
});
function get_search_results() {
//get the selected location_id
var gal_location_id = 0;
//get the selected package
var starting_package_wedding = 1;
var data = "gal_location_id="+gal_location_id+"&starting_package_wedding="+starting_package_wedding;
//var url_to_call = '<?php echo $html->url(array("controller"=>"gal_providers","action"=>"api_search")); ?>';
var url_to_call = "http://localhost/myshaadi/photographers/api_search";
$.ajax({
type: "GET",
url: url_to_call,
// async: false,
dataType: "json",
data: data,
error:function(resp){
},
success: function(resp){
alert('Upto here');
//render_search_result(resp);
}
});
}
</script>
I was expecting an alert of Upto here, but it is not alerting anything after page loads ! Whats wrong?
Notice (8): Undefined variable: javascript [APP\views\layouts\error.ctp, line 8]what does this means - Nitishhttp://localhost/myshaadi/photographers/api_search- Does your localhost not need any ports? - Richard Peck