Hello to everyone, i’m having a big problem with the AJAX and yii2, when i make a ajax petition to my controller (who returns a renderPartial) it returns the content correctly (without any error) but the http header is (500 Internal Server Error)
Cause of this, jQuery thows the “failure” statement and i can’t receive the data of the ajax
My Controller Action code (PHP)
public function actionRenoveSubscription() {
header("Access-Control-Allow-Origin: *");
return $this->renderPartial('subscriptionRenove');
}
Also i tried with the print statement like this
public function actionRenoveSubscription() {
header("Access-Control-Allow-Origin: *");
print $this->renderPartial('subscriptionRenove');
}
And here is my Js (AJAX) code
jQuery("#renovate").click(function() {
jQuery.ajax("<?= Yii::getAlias("@web"); ?>/?r=user-subscription/renove-subscription")
.done(function(data) {
jQuery("#subsContainer").html(data);
})
.fail(function(mp, mp2, data) {
alert("Ha ocurrido un error técnico, \nEl equipo técnico está avisado");
});
});
I’m always recive this error (ISE 500)
But the server returns me the content ‘asd’ in this case (testing) sorry but i can’t attach any image (Cause i’m new on the forum)
Any help? thank’s you very much