dqsp60748
2013-05-30 04:13
浏览 48
已采纳

将json编码的关联数组从php传递给javascript时显示错误

I have an associative array after json_encode like this

{"1":"CourseA", "2":"CourseB"}

and it is stored in a php variable named $jsonObject.Now, I want to send this to a javascript function and use that array inside that function. The function is invoked onclick like this:

 <a href="#" onclick="popup('.$jsonObject.');">link</a>

The problem is: It shows an error:invalid id popup({....

Whats the reason and what should be the solution for that? btw, I am working in moodle and the above link is shown inside a moodle block and declared inside $this->content->text.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题