Jump to content

PHP get data value from ajax


Recommended Posts

Hi, what is the 'q' thing in this PHP AJAX tutorial: http://www.w3schools.com/php/php_ajax_php.asp :


HTML page:



PHP file:



And how PHP read value of an input element (html) to be processed?

The same question if using jquery AJAX..


I'm learning XMLHttpRequest and trying to figure out how PHP get data value from HTML element to be processed. I don't know anything about PHP, I've just started a start.




Link to comment
Share on other sites

In order to learn AJAX it's recommended that you study PHP first. You won't be able to understand what's happening if you don't know PHP.


What you're asking about is a query string. It's used to send information to the server. PHP handles it using $_GET, $_POST and $_REQUEST variables. Read about it here: http://www.w3schools.com/php/php_forms.asp


$_REQUEST has data from GET, POST and COOKIE requests, which means people could use it to send data to your site in a way you didn't want them to, so I don't recommend using $_REQUEST.

Link to comment
Share on other sites

I'm focusing on the XMLHttpRequest.


I was looking for a method to 'Save/Open' file contains values of html elements, and then I found that XMLHttpRequest is a good one for me, like in this tutorial: http://www.w3schools.com/json/json_http.asp.

I create a simple simulation as follows:

  1. User modify values of html elements on the web page (Input values, innerHTML, CSS, etc.).
  2. They can save the new values as a .txt file containing array (json). I create a string as json format template, user can copy them and save it with Notepad as .txt on their PC.
  3. They're going to need to upload the .txt file to our server (I guess this one will need PHP).
  4. Using XMLHttpRequest, as in the tutorial, user can 'open' the web page with 'saved' values from their .txt file.

I tested this by upload my own array .txt and 'open' them using XMLHttpRequest, the web page updated with new values for its elements, it looks good for now. Just like AJAX intro says 'AJAX is about updating parts of a web page, without reloading the whole page.'.


And as for the PHP, I think I'm going to need a classroom to learn them, but thanks for the lesson.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...