Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

When I put this link on the browser it will worked. But, When clicked on the button it will not working. What is the wrong in this code. http://localhost/youtubewebservice/shopCartProductDelete.php?cart_ID=6

$scope.delete = function(cart_ID, index) {
var params = $.param({"cart_ID":cart_ID});

  console.log(cart_ID);
  $http({
    headers: {'Content-Type': 'application/x-www-form-urlencoded'},
    url: 'http://localhost/youtubewebservice/shopCartProductDelete.php?cart_ID=$cart_ID',
    method: "GET",
    data: params
  }).success(function(data){
    $scope.data.splice(index, 1);
  });
} 
<img src="img/removecart.png" ng-click="delete({{produ.cart_ID}}, $index)" style="max-height: 40px;margin-right: 15px;"/>

PHP code

<?php
$con = mysqli_connect("localhost","root","","look4com_lk");
if(isset($_GET['cart_ID'])){
$cart_ID = $_GET['cart_ID'];
$res = "DELETE FROM l4wlk_cart WHERE cart_ID='".$cart_ID."'";
mysqli_query($con, $res);


}

echo json_encode($result);

?>
share|improve this question

See the documentation of ng-click

enter image description here

It uses an expression.

If template was written in the Type column, then you would have written those values in double curly braces {{..}}. But since it accepts an expression, so there's no need to use double curly braces.

Change your <img..> to:

<img src="img/removecart.png" ng-click="delete(produ.cart_ID, $index)" style="max-height: 40px;margin-right: 15px;"/>
share|improve this answer
    
I changed like this ng-click="delete(produ.cart_ID, $index)" but this is not work. – DRK yesterday
    
my javascript code is ok ? – DRK yesterday

Inside angular directives you don't need to parse the angular value. You should change this

<img src="img/removecart.png" ng-click="delete({{produ.cart_ID}}, $index)" style="max-height: 40px;margiurln-right: 15px;"/>

to

<img src="img/removecart.png" ng-click="delete(produ.cart_ID, $index)" style="max-height: 40px;margin-right: 15px;"/>

Update

Try to change your js code as below

$http.get('http://localhost/youtubewebservice/shopCartProductDelete.php', {"cart_ID":cart_ID})
.success(function(data){
   $scope.data.splice(index, 1);
});

Just check with

if(isset($_GET['cart_ID'])){
  $cart_ID = $_GET['cart_ID'];
  $res = "DELETE FROM l4wlk_cart WHERE cart_ID='".$cart_ID."'";
  mysqli_query($con, $res) or mysqli_error($con);
}else{
  die("Param value not set up");
}
share|improve this answer
    
I changed like this ng-click="delete(produ.cart_ID, $index)" but this is not work. – DRK yesterday
    
try console log in controller produ.cart_ID. Share the value – Vineet yesterday
    
When I add this code console.log(cart_ID) cart ID will display. java script code has any error. – DRK yesterday
    
@DRK check edited answer – Vineet yesterday
    
I checked but not work. – DRK yesterday

instead of doing console.log(cart_ID) please check the value of console.log(produ.cart_ID)

share|improve this answer
    
console.log(produ.cart_ID) used this. Then will display error like this. Can't find variable: produ – DRK yesterday
    
you are trying to delete produ.cart_Id and you have your cart_id valu in Cart_Id try delete(Cart_Id,$index) – PJM yesterday
    
then cant delete – DRK yesterday
    
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review – eisbehr yesterday

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.