Php has a way to get the js value.

Source: Internet
Author: User
Php has a way to get the js value. recently I am studying discuz. when I modify the code, I want to assign the js value to the global variable of discuz. how can I do this? Or you can use php to obtain the js value.


Reply to discussion (solution)

Php does not obtain the js value, but the value that js passes to the server! The frontend can transmit data to the backend in two ways: POST GET

$ User = $ _ POST ['user']; // GET the post value in php $ pass = $ _ get ['pass']; // GET The get value in php

The value is generally transmitted through ajax!
So it is not php that gets the js value, but js transfers the data to the server, and php reads Global arrays such as post get!

Php does not obtain the js value, but the value that js passes to the server! The frontend can transmit data to the backend in two ways: POST GET

$ User = $ _ POST ['user']; // GET the post value in php $ pass = $ _ get ['pass']; // GET The get value in php

The value is generally transmitted through ajax!
So it is not php that gets the js value, but js transfers the data to the server, and php reads Global arrays such as post get!


For example, if I write a JS file on the current page and want to get this value on the current page, how can I write it?

What you call ajax is generally transmitted. the page execution sequence is the html code after the php language is parsed and then executed,

What you call ajax is generally transmitted. the page execution sequence is the html code after the php language is parsed and then executed,


How can this be written?


What you call ajax is generally transmitted. the page execution sequence is the html code after the php language is parsed and then executed,


How can this be written?


Are you writing html php and js together? We recommend that you separate all files!
Instance on http://www.w3school.com.cn/php/php_ajax_suggest.asp w3



What you call ajax is generally transmitted. the page execution sequence is the html code after the php language is parsed and then executed,


How can this be written?


Are you writing html php and js together? We recommend that you separate all files!
Instance on http://www.w3school.com.cn/php/php_ajax_suggest.asp w3


I did not write them together. it was directly modified on dz, and I couldn't help it either.

First, find out the execution sequence between the server and the client.
Php is a server-side language.
JS is the client script.

All requests are sent to the client after being executed by the server. Therefore, you must ask the server to obtain the value of the client. the only way is to let the client send a request to the server.
For example, ajax requests

First, find out the execution sequence between the server and the client.
Php is a server-side language.
JS is the client script.

All requests are sent to the client after being executed by the server. Therefore, you must ask the server to obtain the value of the client. the only way is to let the client send a request to the server.
For example, ajax requests


Can this be done on the same page?

It should be handled by passing ajax requests to php.

It should be handled by passing ajax requests to php.


The problem is that it is done in discuz. for common php, you can use ajax.

Does discuz provide ajax. get methods?

Does discuz provide ajax. get methods?


I just learned discuz, but I am not very familiar with it. can you give me a simple example? For example, I want to create a drop-down box and assign the value of the drop-down box to $ _ G ['fid'].

Actually I didn't have discuz, you look at this http://www.baidu.com/s? Ie = UTF-8 & wd = discuz + ajax % E4 % BD % BF % E7 % 94% A8

Actually I didn't have discuz, you look at this http://www.baidu.com/s? Ie = UTF-8 & wd = discuz + ajax % E4 % BD % BF % E7 % 94% A8


Okay. let me check it out. thank you.

Use ajax to pass to php

Use ajax to pass to php


Can you give me an instance?

 

In this way, php can use the js variable value.

 

In this way, php can use the js variable value.


Okay. thank you.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.