dustcomposer Posted October 24, 2014 Share Posted October 24, 2014 Hi, what is the 'q' thing in this PHP AJAX tutorial: http://www.w3schools.com/php/php_ajax_php.asp : HTML page: xmlhttp.open("GET","gethint.php?q="+str,true); PHP file: $q=$_REQUEST["q"]; 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. Thanks! Link to comment Share on other sites More sharing options...
Ingolme Posted October 24, 2014 Share Posted October 24, 2014 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 More sharing options...
dustcomposer Posted October 24, 2014 Author Share Posted October 24, 2014 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: User modify values of html elements on the web page (Input values, innerHTML, CSS, etc.). 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. They're going to need to upload the .txt file to our server (I guess this one will need PHP). 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 More sharing options...
Ingolme Posted October 24, 2014 Share Posted October 24, 2014 You can use AJAX to load information from a text file. In that case you won't need the "&q=" part. If you are curious about query strings you do have to learn PHP. Link to comment Share on other sites More sharing options...
dustcomposer Posted October 25, 2014 Author Share Posted October 25, 2014 If you are curious about query strings you do have to learn PHP. I am. I will need it. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now