asked on
var jsonObject = json.stringify({
'renderedStaticPage': renderedStaticPage,
'newsTickerEnabled': (newsTickerEnabled ? 1 : 0)
});
var messageText = 'ipAddress = ' + Apostrophe
+ strings.excerpt(ipAddress) + Apostrophe
+ CommaSpace + Apostrophe + 'jsonObject = '
+ Apostrophe + jsonObject + Apostrophe;
messages.print(functionName, messageText);
$http({
method: 'POST',
url: ipAddress,
headers : {
'Content-Type': 'application/json; charset=UTF-8'
//'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
data: JSON.stringify(jsonObject),
}).success(function(data, status, headers, config) {
swal('Data sent successfully.', '', 'info');
}).error(function(data, status, headers, config) {
swal('No connection possible!', 'URL: '
+ messageText, 'error');
});
};
<?php
include('./general/connectDB.php');
include('./general/constants.php');
$renderedStaticPage = $_POST['renderedStaticPage'];
$newsTickerEnabled = $_POST['newsTickerEnabled'];
//print "renderedStaticPage = $renderedStaticPage" . $CR; # Test line
//print "newsTickerEnabled = $newsTickerEnabled" . $CR; # Test line
$query = "INSERT INTO StartSite (renderedStaticPage, newsTicker_enabled) VALUES ('"
. $renderedStaticPage . "', " . $newsTickerEnabled . ")";
// Start query
$result = MYSQL_QUERY($query);
//print "query = $query\nresult = $result" . $CR; # Test line
?>
SyntaxError: Unexpected token r in JSON at position 0
at JSON.parse (<anonymous>)
at fromJson (ionic.bundle.js:10063)
at defaultHttpResponseTransform (ionic.bundle.js:18080)
at ionic.bundle.js:18171
at forEach (ionic.bundle.js:9168)
at transformData (ionic.bundle.js:18170)
at transformResponse (ionic.bundle.js:18926)
at processQueue (ionic.bundle.js:23399)
at ionic.bundle.js:23415
at Scope.$eval (ionic.bundle.js:24678)
[…]
var messageText = 'ipAddress = ' + Apostrophe
+ strings.excerpt(ipAddress) + Apostrophe + CommaSpace
+ Apostrophe + 'renderedStaticPage = ' + Apostrophe
+ strings.excerpt(renderedStaticPage) + Apostrophe + CommaSpace
+ 'newsTickerEnabled = ' + strings.excerpt(newsTickerEnabled);
messages.print(functionName, messageText);
$http({
method: 'POST',
url: ipAddress,
headers : {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
data: {
'renderedStaticPage': renderedStaticPage,
'newsTickerEnabled': (newsTickerEnabled ? 1 : 0)
},
}).success(function(data, status, headers, config) {
swal('Data sent successfully.', '', 'info');
}).error(function(data, status, headers, config) {
swal('No connection possible!', 'URL: '
+ messageText, 'error');
});
[…]