Jump to content

POST STRINGS


yakult

Recommended Posts

PRACTICE IS AVAILABLE TO USE A TAG HTML AND SHOW IN PHP RESULT, TO SHOW WITH MYSQL RETURNING LOGIN! echo "<div id=\"login\"></div>";echo "<form action=\"javascript:AbrirPag()\" method=\"post\">";echo "<input name=\"login\" type=\"text\" id=\"login\" value=\"$login\"/>";echo "<input name=\"pass\" type=\"password\" id=\"pass\" value=\"pass\"/>";echo "<input type=\"submit\" name=\"Submit\" value=\"Login\"/>";echo "</form>"; PLACE A STRING (MADE TO ILMO. IACAMI) <script type="text/javascript">function loadXMLDoc(){var xmlhttp;if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("conteudo").innerHTML=xmlhttp.responseText; } }xmlhttp.open("GET","ajax_info.txt",true);xmlhttp.send();}</script> MADE WITH STRING!!! function createObject() {var request_type;var browser = navigator.appName;if(browser == "Microsoft Internet Explorer"){request_type = new ActiveXObject("Microsoft.XMLHTTP");}else{request_type = new XMLHttpRequest();}return request_type;}var http = createObject(); HOW TO GT STRING IN THE PAGE?

Link to comment
Share on other sites

Why are you sending you ajax call to a text file when you could it to a php file?

Edited by niche
Link to comment
Share on other sites

Those examples don't really go together. The first one uses a function called AbrirPag, the second has loadXMLDoc, and the third has CreateObject. If you're trying to use ajax to update the page, the loadXMLDoc function has an example. That's what this line does: document.getElementById("conteudo").innerHTML=xmlhttp.responseText; xmlhttp.responseText contains the response from the server.

Link to comment
Share on other sites

BTW, how does that work, sending an ajax call to a text file? I didn't know a txt file was executable except with php files in a manner of speaking. Hadn't read http://www.w3schools.com/ajax/ajax_xmlhttprequest_send.asp before and had no idea you could send to a txt file.

Link to comment
Share on other sites

BTW, how does that work, sending an ajax call to a text file? I didn't know a txt file was executable except with php files in a manner of speaking.
There's no reason it needs to be executable. You send a request to the server, and the server returns a response. Any URL will work with ajax, you're just handling the response manually instead of letting the browser render it. You can send an ajax request for an image if you want, you'll get the binary data back that the server would normally send to the browser. There's very little difference in the request your browser normally sends and an ajax request. It's still a request from the browser and response from the server, that's all HTTP is.
Link to comment
Share on other sites

I can't think of a reason why I'd do that or send an ajax call to a jpg for that matter. Although, until yesterday, I hadn't conceived that javascript could be rendered in php or that I was about to have a reason to do that. What would be a good general reason to send to a non executable file instead of one that's executable? My mind is open, but I can't think of a reason why I might need to do that someday.

Link to comment
Share on other sites

As far as a browser is concerned everything is non-executable. All it sees is the response from the server. One example may be a request for a static XML file that gets updated from something else instead of being generated dynamically every request.

Link to comment
Share on other sites

So, given:

 xmlhttp.open("GET","ajax_info.txt",true);

You're asking the server to send "ajax_info.txt" back in the xmlhttp.responseText, right?

Link to comment
Share on other sites

I understand. I hadn't ever thought of it that way. Thanks again justsomeguy.

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...