1

enter image description hereI want to get an object in this style

var zoz2= {
            "11-30--0001": "<a href=\"https:\/\/www.dooz.ps\/p\/107229\" >\u0625\u0637\u0644\u0627\u0642 \u0627\u0644\u0645\u0648\u0633\u0645 \u0627\u0644\u062e\u0627\u0645\u0633 \u0644\u0628\u0631\u0646\u0627\u0645\u062c \"\u062a\u0645\u064a\u0651\u0632\" <\/a>",
        };

i want to declarate it in laravel, i tried this but failed

$z=response()->json([
                "01-06-2019" => "<a href='https://www.dooz.ps/p/112996' >معرض وجوه للأقنعة</a>"
            ]);

then in JavaScript

console.log('{!! $z !!}');

but failed, In short, I want to get a data show in the console this way, how to Declarate here at the php https://i.sstatic.net/lJd6f.png 2

1 Answer 1

1

i solve it, in laravel must writ like this

$z=collect();
$z->put('06-16-2019', "<a href='/intvi/anylink' >معرض وجوه للأقنعة</a>");
....
$z=json_encode($z);

and use it in javascript

JSON.parse(` {!! $z !!}`)
Sign up to request clarification or add additional context in comments.

1 Comment

You don't need the JSON.parse (and I suspect it'll break in some cases). You can just do var zoz2 = {!! $z !!};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.