TypeError: Cannot read property 'param' of undefined in angularjs












0














$scope.productDetails = {};
$scope.getProductDetailById = function(arg) {

var data = $.param({
id: arg
});

$http({
method: 'POST',
url: 'http://' + $scope.url + '/scripts/viewProductById.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;'
},
data: data
})
.then(function(response) {
$scope.productDetails = response.data;
$location.path('/single_product');
},
function(response) {
//alert('wrong');
})
}




Getting this error in console:




TypeError: Cannot read property 'param' of undefined




Here is my Backend code which is written in PHP and I have checked with postman and data is fetching in json:



session_start();
require 'db.php';
$id = $_POST['id'];
$sql = "SELECT * FROM product WHERE id='$id'";
$qur = $connection->query($sql);
$r = mysqli_fetch_assoc($qur);
$msg = array("id" => $r['id'],"name" => $r['name'],"category" => $r['category'],"material" => $r['material'],
"pattern" => $r['pattern'],"occasion" => $r['occasion'],"length" => $r['length'],"width" => $r['width'],
"wash_care" => $r['wash_care'],"color" => $r['color'],"stock" => $r['stock'],"new_price" => $r['new_price'],
"old_price" => $r['old_price'],"delivery_in" => $r['delivery_in'],"image_one" => $r['image_one'],
"image_two" => $r['image_two'],"image_three" => $r['image_three'],"image_four" => $r['image_four'],
"image_five" => $r['image_five'],"description" => $r['description'],"date" => $r['date']);

$json = $msg;

header('content-type: application/json');
echo json_encode($json);
@mysqli_close($connection);


After changing :



var data = {
id: arg
};


Getting Empty data



enter image description here










share|improve this question
























  • param is a property of $, which is undefined. What is $? jQuery? Do you have a script for it?
    – Aleksey Solovey
    Nov 20 '18 at 10:08










  • No, Just I have used jquery library and angular.min.js
    – Chit
    Nov 20 '18 at 10:12












  • I am calling lot of function but only this function I am getting like this.
    – Chit
    Nov 20 '18 at 10:14










  • can you not just call $http.post('http://'+ $scope.url +'/scripts/viewProductById.php', { id:arg }) ?
    – Aleksey Solovey
    Nov 20 '18 at 10:15










  • But same code working in my admin dashboard project
    – Chit
    Nov 20 '18 at 10:17
















0














$scope.productDetails = {};
$scope.getProductDetailById = function(arg) {

var data = $.param({
id: arg
});

$http({
method: 'POST',
url: 'http://' + $scope.url + '/scripts/viewProductById.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;'
},
data: data
})
.then(function(response) {
$scope.productDetails = response.data;
$location.path('/single_product');
},
function(response) {
//alert('wrong');
})
}




Getting this error in console:




TypeError: Cannot read property 'param' of undefined




Here is my Backend code which is written in PHP and I have checked with postman and data is fetching in json:



session_start();
require 'db.php';
$id = $_POST['id'];
$sql = "SELECT * FROM product WHERE id='$id'";
$qur = $connection->query($sql);
$r = mysqli_fetch_assoc($qur);
$msg = array("id" => $r['id'],"name" => $r['name'],"category" => $r['category'],"material" => $r['material'],
"pattern" => $r['pattern'],"occasion" => $r['occasion'],"length" => $r['length'],"width" => $r['width'],
"wash_care" => $r['wash_care'],"color" => $r['color'],"stock" => $r['stock'],"new_price" => $r['new_price'],
"old_price" => $r['old_price'],"delivery_in" => $r['delivery_in'],"image_one" => $r['image_one'],
"image_two" => $r['image_two'],"image_three" => $r['image_three'],"image_four" => $r['image_four'],
"image_five" => $r['image_five'],"description" => $r['description'],"date" => $r['date']);

$json = $msg;

header('content-type: application/json');
echo json_encode($json);
@mysqli_close($connection);


After changing :



var data = {
id: arg
};


Getting Empty data



enter image description here










share|improve this question
























  • param is a property of $, which is undefined. What is $? jQuery? Do you have a script for it?
    – Aleksey Solovey
    Nov 20 '18 at 10:08










  • No, Just I have used jquery library and angular.min.js
    – Chit
    Nov 20 '18 at 10:12












  • I am calling lot of function but only this function I am getting like this.
    – Chit
    Nov 20 '18 at 10:14










  • can you not just call $http.post('http://'+ $scope.url +'/scripts/viewProductById.php', { id:arg }) ?
    – Aleksey Solovey
    Nov 20 '18 at 10:15










  • But same code working in my admin dashboard project
    – Chit
    Nov 20 '18 at 10:17














0












0








0


1





$scope.productDetails = {};
$scope.getProductDetailById = function(arg) {

var data = $.param({
id: arg
});

$http({
method: 'POST',
url: 'http://' + $scope.url + '/scripts/viewProductById.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;'
},
data: data
})
.then(function(response) {
$scope.productDetails = response.data;
$location.path('/single_product');
},
function(response) {
//alert('wrong');
})
}




Getting this error in console:




TypeError: Cannot read property 'param' of undefined




Here is my Backend code which is written in PHP and I have checked with postman and data is fetching in json:



session_start();
require 'db.php';
$id = $_POST['id'];
$sql = "SELECT * FROM product WHERE id='$id'";
$qur = $connection->query($sql);
$r = mysqli_fetch_assoc($qur);
$msg = array("id" => $r['id'],"name" => $r['name'],"category" => $r['category'],"material" => $r['material'],
"pattern" => $r['pattern'],"occasion" => $r['occasion'],"length" => $r['length'],"width" => $r['width'],
"wash_care" => $r['wash_care'],"color" => $r['color'],"stock" => $r['stock'],"new_price" => $r['new_price'],
"old_price" => $r['old_price'],"delivery_in" => $r['delivery_in'],"image_one" => $r['image_one'],
"image_two" => $r['image_two'],"image_three" => $r['image_three'],"image_four" => $r['image_four'],
"image_five" => $r['image_five'],"description" => $r['description'],"date" => $r['date']);

$json = $msg;

header('content-type: application/json');
echo json_encode($json);
@mysqli_close($connection);


After changing :



var data = {
id: arg
};


Getting Empty data



enter image description here










share|improve this question















$scope.productDetails = {};
$scope.getProductDetailById = function(arg) {

var data = $.param({
id: arg
});

$http({
method: 'POST',
url: 'http://' + $scope.url + '/scripts/viewProductById.php',
headers: {
'Content-Type': 'application/x-www-form-urlencoded;'
},
data: data
})
.then(function(response) {
$scope.productDetails = response.data;
$location.path('/single_product');
},
function(response) {
//alert('wrong');
})
}




Getting this error in console:




TypeError: Cannot read property 'param' of undefined




Here is my Backend code which is written in PHP and I have checked with postman and data is fetching in json:



session_start();
require 'db.php';
$id = $_POST['id'];
$sql = "SELECT * FROM product WHERE id='$id'";
$qur = $connection->query($sql);
$r = mysqli_fetch_assoc($qur);
$msg = array("id" => $r['id'],"name" => $r['name'],"category" => $r['category'],"material" => $r['material'],
"pattern" => $r['pattern'],"occasion" => $r['occasion'],"length" => $r['length'],"width" => $r['width'],
"wash_care" => $r['wash_care'],"color" => $r['color'],"stock" => $r['stock'],"new_price" => $r['new_price'],
"old_price" => $r['old_price'],"delivery_in" => $r['delivery_in'],"image_one" => $r['image_one'],
"image_two" => $r['image_two'],"image_three" => $r['image_three'],"image_four" => $r['image_four'],
"image_five" => $r['image_five'],"description" => $r['description'],"date" => $r['date']);

$json = $msg;

header('content-type: application/json');
echo json_encode($json);
@mysqli_close($connection);


After changing :



var data = {
id: arg
};


Getting Empty data



enter image description here







php angularjs json






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 11:20

























asked Nov 20 '18 at 10:06









Chit

839




839












  • param is a property of $, which is undefined. What is $? jQuery? Do you have a script for it?
    – Aleksey Solovey
    Nov 20 '18 at 10:08










  • No, Just I have used jquery library and angular.min.js
    – Chit
    Nov 20 '18 at 10:12












  • I am calling lot of function but only this function I am getting like this.
    – Chit
    Nov 20 '18 at 10:14










  • can you not just call $http.post('http://'+ $scope.url +'/scripts/viewProductById.php', { id:arg }) ?
    – Aleksey Solovey
    Nov 20 '18 at 10:15










  • But same code working in my admin dashboard project
    – Chit
    Nov 20 '18 at 10:17


















  • param is a property of $, which is undefined. What is $? jQuery? Do you have a script for it?
    – Aleksey Solovey
    Nov 20 '18 at 10:08










  • No, Just I have used jquery library and angular.min.js
    – Chit
    Nov 20 '18 at 10:12












  • I am calling lot of function but only this function I am getting like this.
    – Chit
    Nov 20 '18 at 10:14










  • can you not just call $http.post('http://'+ $scope.url +'/scripts/viewProductById.php', { id:arg }) ?
    – Aleksey Solovey
    Nov 20 '18 at 10:15










  • But same code working in my admin dashboard project
    – Chit
    Nov 20 '18 at 10:17
















param is a property of $, which is undefined. What is $? jQuery? Do you have a script for it?
– Aleksey Solovey
Nov 20 '18 at 10:08




param is a property of $, which is undefined. What is $? jQuery? Do you have a script for it?
– Aleksey Solovey
Nov 20 '18 at 10:08












No, Just I have used jquery library and angular.min.js
– Chit
Nov 20 '18 at 10:12






No, Just I have used jquery library and angular.min.js
– Chit
Nov 20 '18 at 10:12














I am calling lot of function but only this function I am getting like this.
– Chit
Nov 20 '18 at 10:14




I am calling lot of function but only this function I am getting like this.
– Chit
Nov 20 '18 at 10:14












can you not just call $http.post('http://'+ $scope.url +'/scripts/viewProductById.php', { id:arg }) ?
– Aleksey Solovey
Nov 20 '18 at 10:15




can you not just call $http.post('http://'+ $scope.url +'/scripts/viewProductById.php', { id:arg }) ?
– Aleksey Solovey
Nov 20 '18 at 10:15












But same code working in my admin dashboard project
– Chit
Nov 20 '18 at 10:17




But same code working in my admin dashboard project
– Chit
Nov 20 '18 at 10:17












1 Answer
1






active

oldest

votes


















0














You don't have to use it like this.



var data = $.param({
id: arg
});


The data variable can just be an Object Literal like so.



var data = {
id: arg
};





share|improve this answer





















  • Status is 200 but data is empty
    – Chit
    Nov 20 '18 at 11:44










  • @Chit that depends on your backend. e.g. with PHP, double check if you are using echo json_encode(...)
    – Aleksey Solovey
    Nov 20 '18 at 14:38










  • @Chit Please show us your server-side code.
    – holydragon
    Nov 21 '18 at 2:04










  • Uploaded please check it
    – Chit
    Nov 21 '18 at 5:04






  • 1




    try stackoverflow.com/questions/15485354/…
    – holydragon
    Nov 21 '18 at 9:33











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390596%2ftypeerror-cannot-read-property-param-of-undefined-in-angularjs%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














You don't have to use it like this.



var data = $.param({
id: arg
});


The data variable can just be an Object Literal like so.



var data = {
id: arg
};





share|improve this answer





















  • Status is 200 but data is empty
    – Chit
    Nov 20 '18 at 11:44










  • @Chit that depends on your backend. e.g. with PHP, double check if you are using echo json_encode(...)
    – Aleksey Solovey
    Nov 20 '18 at 14:38










  • @Chit Please show us your server-side code.
    – holydragon
    Nov 21 '18 at 2:04










  • Uploaded please check it
    – Chit
    Nov 21 '18 at 5:04






  • 1




    try stackoverflow.com/questions/15485354/…
    – holydragon
    Nov 21 '18 at 9:33
















0














You don't have to use it like this.



var data = $.param({
id: arg
});


The data variable can just be an Object Literal like so.



var data = {
id: arg
};





share|improve this answer





















  • Status is 200 but data is empty
    – Chit
    Nov 20 '18 at 11:44










  • @Chit that depends on your backend. e.g. with PHP, double check if you are using echo json_encode(...)
    – Aleksey Solovey
    Nov 20 '18 at 14:38










  • @Chit Please show us your server-side code.
    – holydragon
    Nov 21 '18 at 2:04










  • Uploaded please check it
    – Chit
    Nov 21 '18 at 5:04






  • 1




    try stackoverflow.com/questions/15485354/…
    – holydragon
    Nov 21 '18 at 9:33














0












0








0






You don't have to use it like this.



var data = $.param({
id: arg
});


The data variable can just be an Object Literal like so.



var data = {
id: arg
};





share|improve this answer












You don't have to use it like this.



var data = $.param({
id: arg
});


The data variable can just be an Object Literal like so.



var data = {
id: arg
};






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 20 '18 at 10:56









holydragon

1,2481618




1,2481618












  • Status is 200 but data is empty
    – Chit
    Nov 20 '18 at 11:44










  • @Chit that depends on your backend. e.g. with PHP, double check if you are using echo json_encode(...)
    – Aleksey Solovey
    Nov 20 '18 at 14:38










  • @Chit Please show us your server-side code.
    – holydragon
    Nov 21 '18 at 2:04










  • Uploaded please check it
    – Chit
    Nov 21 '18 at 5:04






  • 1




    try stackoverflow.com/questions/15485354/…
    – holydragon
    Nov 21 '18 at 9:33


















  • Status is 200 but data is empty
    – Chit
    Nov 20 '18 at 11:44










  • @Chit that depends on your backend. e.g. with PHP, double check if you are using echo json_encode(...)
    – Aleksey Solovey
    Nov 20 '18 at 14:38










  • @Chit Please show us your server-side code.
    – holydragon
    Nov 21 '18 at 2:04










  • Uploaded please check it
    – Chit
    Nov 21 '18 at 5:04






  • 1




    try stackoverflow.com/questions/15485354/…
    – holydragon
    Nov 21 '18 at 9:33
















Status is 200 but data is empty
– Chit
Nov 20 '18 at 11:44




Status is 200 but data is empty
– Chit
Nov 20 '18 at 11:44












@Chit that depends on your backend. e.g. with PHP, double check if you are using echo json_encode(...)
– Aleksey Solovey
Nov 20 '18 at 14:38




@Chit that depends on your backend. e.g. with PHP, double check if you are using echo json_encode(...)
– Aleksey Solovey
Nov 20 '18 at 14:38












@Chit Please show us your server-side code.
– holydragon
Nov 21 '18 at 2:04




@Chit Please show us your server-side code.
– holydragon
Nov 21 '18 at 2:04












Uploaded please check it
– Chit
Nov 21 '18 at 5:04




Uploaded please check it
– Chit
Nov 21 '18 at 5:04




1




1




try stackoverflow.com/questions/15485354/…
– holydragon
Nov 21 '18 at 9:33




try stackoverflow.com/questions/15485354/…
– holydragon
Nov 21 '18 at 9:33


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390596%2ftypeerror-cannot-read-property-param-of-undefined-in-angularjs%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

If I really need a card on my start hand, how many mulligans make sense? [duplicate]

Alcedinidae