0

I feel like I'm missing something very obvious, all I need to do is return plain text (not JSON) in response to an action. If I use returnJson() it returns the value with quotation marks around it. I'm dealing with a closed system that expects a VERY specific format, so the added quotations cause the submission to fail.

So for added clarification:

$returnValue = "abc,123"
$this->returnJson($returnValue)

I get: "abc,123"

I NEED: abc,123

1

So I realized I can just do die("abc,123") and get the result I need. I am definitely open to better or more "correct" solutions though.

1

You can just use PHP's echo method to directly output to the browser.

$returnValue = "abc,123";
echo $returnValue;
1

Nothing wrong with a plain old echo() statement, even returnJson() essentially just echoes your data (after JSON encoding it, of course).

If it feels better, you can use $this->renderText('abc,123'); – although it'll also basically just call echo() for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.