First of all, this works perfectly in Firefox and Internet Explorer. I have an ajax call that is retrieving data (the review and the rating). This is what becomes the output or data for profile.php. The problem is that in Chrome, I'm not getting back the $review variable. I'm getting everything else but that. It's not even showing up in the Chrome developer tools page source.
It works as it should in Firefox and IE, without any problems.
The ONLY place the submitted text shows up in Chrome is in the "Request Payload" section under the "Headers" tab under "Network". I've tried messing with the contenttype but it only made things worse.
Here's the ajax call in profile.php:
$(document).ready(function() {
$('#reviewbutton').on('click', function() {
$("#enterreview").submit(function(e) {
var formObj = $(this);
var formURL = formObj.attr("action"); // "/upload.php"
var formData = new FormData(this);
$.ajax({
url: formURL,
type: 'POST',
data: formData, //Stops working correctly if I change this
mimeType: "text/html",
contentType: false, //Stops working correctly if I change this
cache: false,
processData: false,
success: function(data, textStatus, jqXHR) {
alert(data);
$('#reviewsection').prepend(data);
$('.reviewinput').val('');
},
error: function(jqXHR, textStatus, errorThrown) {
alert(jqXHR);
}
});
return false;
});
});
});
Here's upload.php:
<?php
require 'autoload.php';
$app_id = (censored);
$rest_key = (censored);
$master_key = (censored);
use Parse\ParseClient;
use Parse\ParseObject;
use Parse\ParseQuery;
use Parse\ParseACL;
use Parse\ParsePush;
use Parse\ParseUser;
use Parse\ParseInstallation;
use Parse\ParseException;
use Parse\ParseAnalytics;
use Parse\ParseFile;
use Parse\ParseCloud;
use Parse\ParseRelation;
use Parse\ParseSessionStorage;
session_start();
ParseClient::initialize( $app_id, $rest_key, $master_key );
$currentUser = ParseUser::getCurrentUser();
if ($currentUser) {
//If it's a review
if(isset($_POST['enterreview'])){
header("Content-type:text/HTML");
$review = $_POST['enterreview'];
$star = $_POST['stars'];
$whoseprofile = $_SERVER["QUERY_STRING"];
$reviews = new ParseObject("Reviews");
$reviews->set("text", $review);
$reviews->set("User", $whoseprofile);
$reviews->set("Rating", $star);
$reviews->save();
//POPULATE REVIEWS
$query = new ParseQuery('Reviews');
$query->equalTo("User", $whoseprofile);
$query->descending('createdAt');
$query->limit(6);
$results = $query->find();
for ($i = 0; $i < count($results); $i++) {
$review = $results[$i]->get("text"); //This is the problem variable.
$date = $results[$i]->getCreatedAt();
$commentrating = intval($results[$i]->get("Rating"), 10);
header('Content-Type: text/html; charset=UTF-8');
echo '<input id="input-id' . $i . '" type="number" class="rating" min=0 max=5 step=1 data-size="xs" data-show-caption="false" data-show-clear="false" readonly="false">
<p class="review">' . $review . '</p>' . //The problem variable.
'<script>
$("#input-id' . $i . '").rating("update", ' . $commentrating . ');
</script>'
;
}
exit();
}
} else {
header("Location: /login");
exit();
}
?>
I would appreciate any help at all. It's been one thing after another.
Aucun commentaire:
Enregistrer un commentaire