0

The ${elem.id} before read more section is not working.

My code

var tr = `<div class="course-content">
                      <h3><a href="">${elem.title}</a></h3>
                          <p>${elem.description}</p>
                             <a class="default-btn" href="{{route('course.details',${elem.id})}}">read more</a>
                  </div> 
               </div>
           </div>`;    
                            
  $('#courses').append(tr);
5
  • 2
    You can't put jQuery variables into PHP functions because, when jQuery is processed, PHP is already processed into HTML. Commented Aug 11, 2021 at 6:50
  • Ok thanks for the answer, so how should I pass this id to the route? Commented Aug 11, 2021 at 6:55
  • 1
    I did something like this and worked: <a class="default-btn" href="courses/${elem.id}">read more</a> Commented Aug 11, 2021 at 7:08
  • Yep, that's okay Commented Aug 11, 2021 at 7:33
  • You can follow this link stackoverflow.com/questions/29308441/… Commented Aug 11, 2021 at 7:54

0

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.