0

当尝试通过 php require_once() 包含 jquery 库时,我发现调用 JQuery UI 的 .dialog() 组件会产生错误消息:

$("#dialog").dialog 不是函数

这对我来说似乎很奇怪,因为在检查 DOM 时,我看到预期的 html 标记被呈现为:

<link rel="stylesheet" href="/scripts/css/smoothness/jquery-ui-1.8.17.custom.css" type="text/css" />

有谁知道为什么通过 php 的 require_once/include_once 包含 html 片段会导致这个问题?

4

1 回答 1

2

A server-side php's require_once/include_once has ABSOLUTELY. NOTHING. TO DO with whatever HTML issues on the client side.

This is most basic rule a web-developer have to learn.

You have to find out a client side issue and fix it.

Always treat any HTML/JS outputted via PHP as native HTML/JS.
There is no difference on the client side.

The algorithm of spotting down the problem is always the same:

  1. Create a clean client-based code with no PHP at all.
  2. Make it work
  3. Let PHP output this code.
  4. If something goes wrong - COMPARE THE CODES. Find out the differencies.
  5. Correct them.
于 2012-03-06T04:20:40.083 回答