多参数onclick事件

Multiple parameters onclick event

当使用 onclick 事件传递多个参数时,我的代码出现语法错误。当它达到三个参数时,我得到错误。我的代码与本地主机没有问题,并且按预期工作。谢谢你的帮助。

这是我的代码:

onclick="editPost({{$post->id}},'{{$post->title}}','{{$post->description}}','{{$post->shortDesc}}','{{$post->caption}}','{{$post->author}}')"

我重新检查了我的数据并注意到我也有新行。所以为了逃避新行和 qoutes 我使用了这个代码:

'{{ preg_replace( '/\r|\n/', '', addslashes($yourstring))  }}'

感谢大家的帮助! :)