By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,677 Members | 1,188 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,677 IT Pros & Developers. It's quick & easy.

not able to update the data thro ajax send

P: 67
hi,
On a test page i try to insert some values thru post method but the values which i send is not replaced in the url which i specify. I get the code found in the page and not the updated one.

My Code

after creating the xmlhttp object

temp ="";

function ajxReq(){
url ="http://192.168.1.41/ajaxsend/login.php?unameTxt=" +document.getElementById('loginName').value+"&pwdT xt=" +document.getElementById('loginPassword').value;
xmlhttp.open("POST",url,true)
xmlhttp.onreadystatechange = loadPage;
xmlhttp.send(null)
}

function loadPage(){
// on status=200
document.getElementById("respdiv").innerHTML = xmlHttp.responseTEXT;
alert("The Div \t"+document.getElementById("respdiv").innerHTML );
// this gives the raw file not the updated one
}

function sendParam(){
temp = '"name="+document.getElementById(\'loginName\').va lue+"password="
+document.getElementById(\'loginPassword\').value' ;
ajxReq();
}
</script>
</head>
<table border="0" cellspacing="0" cellpadding="0" width="300">
<tr>
<td>User Name</td>
<td><input type="text" name="unameTxt" id="loginName" /></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="pwdTxt" id="loginPassword" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" value="Login" onclick="sendParam();"/></td>
</tr>
</table>
<div id="respdiv" style="border:1px dashed orange"></div>
</html>

i tried thru xmlHttp.send(temp) ............. giving the static url with parameters...

Nothig is working

php file
******

<?php
$uname = $_POST["unameTxt"];
$pwd = $_POST["pwdTxt"];
echo "User Name :".$uname."<br>Password :".$pwd;
?>


Looking for a reply to proceed further.

I have another doubt too. IF it is working fine with response text i dont have an idea of structure of the xml doc formed .... Looking for an comment on this too.
Jun 21 '07 #1
Share this Question
Share on Google+
7 Replies


P: 67
hi,
finally i got it
set the request header content -type to
application/x-www-form-urlencoded
then send the string values in xmlhttp.send() in the same way as in get
Jun 22 '07 #2

P: 67
hi,
finally i got it
set the request header content -type to
application/x-www-form-urlencoded
then send the string values in xmlhttp.send() in the same way as in get

but is there a way post a xml to update the file. Iknow it can be done then if its so.
do i need to parse the xml doc in the page where the data is received.

Looking for for a reply.

Thanks in advance for a reply.
Jun 22 '07 #3

acoder
Expert Mod 15k+
P: 16,027
but is there a way post a xml to update the file. Iknow it can be done then if its so.
do i need to parse the xml doc in the page where the data is received.
Update the file where?
Jun 22 '07 #4

P: 67
Update the file where?
I have an xml file in my server. I get an responseXML when the page is called. I manupulate the xml with DOM and change the values of some nodes. and send the xml to the same file.Now! If i get the access the page,responseXML the changes that i made are not effected.

What to do to replace the xml or replace the node in the server. I dont have any idea. How do i receive the data at the server as an xml itself OR in what format is the xml received. I set the RequestHeader as application/xml.

Looking Forward for a reply.
Jun 25 '07 #5

acoder
Expert Mod 15k+
P: 16,027
See the last example in this page. The header is set as "text/xml" and the xml is sent as a string using the send method.
Jun 25 '07 #6

P: 67
See the last example in this page. The header is set as "text/xml" and the xml is sent as a string using the send method.
Thanks but.. ,I know this but i have no idea of how to receive the xml in the server or the url specified. i.e receive the xml sent thru xmlhttp.send(xmlstr) and workaround with it in the server side file.

If the string is assigned to a variable then i can retrive the value of the vriable in _POST[] method in php but is there a way to get the strin as it is (like the link shown by you) and then play with the xml in the server side to update the file.

Thanks in advance
looking for a reply.
Jun 26 '07 #7

acoder
Expert Mod 15k+
P: 16,027
That's a PHP question. Since this is different question to the original one, I suggest you start a new thread in the PHP forum for this.
Jun 26 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.