My current code is like this & amp; lt; html & amp; gt; & amp; lt; head & amp; gt; & amp; lt; title & amp; gt; untitledDocument & amp; lt; title & amp; gt; {code ...} & amp; lt; head & amp; gt; & amp; lt; body & amp; gt; & amp; lt; inputtype & quot; button & quot; onClick & quot; javascript: test (); & quot; & amp; gt; my current code is like this
Untitled Document
《script》 function test(){
{$result} >"; ?> }《script》
But this is wrong.
What should I do?
Reply content:
My current code is like this.
Untitled Document
《script》 function test(){
{$result} >"; ?> }《script》
But this is wrong.
What should I do?
After php is executed on the backend, it is returned to the front-end, and the php code is invisible to the front-end. Do not believe you right-click to view the source code?
A simple method is to write a php file and call it using ajax at the front end. I feel that you lack a lot of knowledge. I don't suggest learning php first. it is easy to learn. You can first learn about C # or Java website development and then come back to learn about php and then feel what php has done.
When the subject asks this question, you do not understand B/s or HTTP.
Each time a browser sends a request, the server processes the request and returns the result to the browser. Only relevant resource files (such as HTML, CSS, JS, and images) can be viewed at the front end, and the server-side code cannot be seen.
To run the code on the server, you must send a request to the server through a browser, such as opening a page, submitting a form, and AJAX.
It seems like you want to send an asynchronous request on the browser side, you can implement it through AJAX.
PHP is parsed on the server side, while js is parsed on the browser. The php code segment sends the html file to the browser only after it is run on the server side, at this time, it has nothing to do with the trigger button. we recommend that you use $ According to your actual needs. get (), $. post (), $. ajax () these encapsulated ajax functions can easily meet your needs.
The error is caused by your PHP code. The final output content is not JavaScript code.
So the error.
《script》 function test(){
{$result} >"; ?> }《script》
The final output content of your PHP code block may be
"
Xxxxxx
"'
Is HTML, not JS code, so the error ..
There is a method called rpc that is exactly what you need
This is not the case. the frontend and backend are separated.