Hi @nolimits4web , @rajkaruna ,
I have these below code to load data on a page, but not working. Any suggestion?
<script>
return {
on: {
pageInit: function() {
var app = this.$app;
var Id = app.ls.getItem('id');
app.request({
type: "POST",
url: "pages/process.php",
data: {Id:Id},
dataType: 'json',
cache: false,
success: function(data, status, xhr){
obj = JSON.parse(data);
$$(obj).each(function() {
$$("#textbox").val(obj.Id);
});
},
error: function(status, xhr) { // if error occured
console.log("Error occured, please try again.");
}
});
}
},
}
</script>
What is exactly not working here?
Hi @Yudistira ,
As er shared code, its should work… Any console error.
Note: Make sure that your sending data correctly
hi @nolimits4web ,
the value not shown on the textbox, normally it’s shown.
I’m using that code for long time, only on fw7 I cannot achieve that
hi @rajkaruna ,
code is working, I’m using it for many years. error show “Error occured, please try again.”
Hi @Yudistira ,
Try your code with JSON stringify data like bewlow
data : JSON.stringify ({“Id”: “Id”})
rajkaruna:
JSON.stringify
Hi @rajkaruna ,
still not working, the output on process.php on chrome dev is like below
{ textbox: "test5"}
textbox
:
"test5"
I’m still confused , I want to achieve when I click listview, new page will open and load the data on textbox. I’m open the page using below code on app.js
$$('#ListView').on('click','li', function(e){
var id = $$(this).attr('value');
app.ls.setItem('id', id);
app.router.navigate({
url: 'edit/',
force: true,
ignoreCache: true
});
});
Hi @nolimits4web , @rajkaruna ,
I’m commenting code below and suddenly everything works as expected. Please suggest.
app.request({
type: "POST",
url: "pages/process.php",
data: {Id:Id},
dataType: 'json',
cache: false,
success: function(data, status, xhr){
obj = JSON.parse(data);
//$$(obj).each(function() { -----COMMMENT
$$("#textbox").val(obj.Id);
//}); -----COMMENT
},
error: function(status, xhr) { // if error occured
console.log("Error occured, please try again.");
}
});
Please refer this.
We thought that you are using jQuery.
I’m using jquery, it’s true without $.each is working, but when I click other data on listview the output is error, have to use $.each. any idea what code I have to write?
working using code below on success
$.each(data, function (index, value) {
$$("#textbox").val(value.id);
});
I’m try this code not working
myApp.request({
type: “GET”,
url: global_url + “api/Notifications”,
data: {},
cache: true,
success: function (response) {
var response = JSON.parse(response);
console.log(response.responseText);
$$(response.responseText).each(function () {
console.log("Raji1");
});
console.log("Raji123");
},
error: function (status, xhr) { // if error occured
console.log("Error occured, please try again.");
}
});
below code not working how solve
$$(response.responseText).each(function () {
});
Hi @Rajeswari_Nehru
try this code
myApp.request({
type: “GET”,
url: global_url + “api/Notifications”,
data: {}, //what is the GET variable???
dataType:'json',
cache: false,
success: function (response) {
$.each(function (index, value) {
console.log(value.responseText);
});
},
error: function (status, xhr) { // if error occured
console.log("Error occured, please try again.");
}
});
I am try this code
$.each(function (index, value) {
console.log(value.responseText);
});
But not working for each function