Wednesday, March 21, 2012

xmlhttprequest "post"

hi there...

i started to using xmlhttprequest and i able to write few pages using "get"

but wondering how can i do using "post"

i have a data-entry page and i grab all the values and post to db

any sample code?

thanks.

from googling.

top 2 of the search

http://www.openjs.com/articles/ajax_xmlhttp_using_post.php
http://www.devx.com/DevX/Tip/17500


busyweb:

from googling.

top 2 of the search

http://www.openjs.com/articles/ajax_xmlhttp_using_post.php
http://www.devx.com/DevX/Tip/17500


i did google and i have seen the above two links but its not complete and i'm still looking for the part where/how do i put the data into db

what i mean by this below code:

var objHTTP, strResult;
objHTTP = new ActiveXObject('Microsoft.XMLHTTP');
objHTTP.Open('POST',"OtherPage.asp",false);
objHTTP.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');

objHTTP.send("id=1&user="+txtUser.value+"&password="+txtPassword.value);

strResult=objHTTP.responseText;<<<< after you havestrResult do you split the data ?


If you're using the asp.net ajax framework (as posting on this forum would indicate), then by far your easiest method is to use the Sys.Net.WebRequest javascript method that you can find inhttp://ajax.asp.net/docs

paul.vencill:

If you're using the asp.net ajax framework (as posting on this forum would indicate), then by far your easiest method is to use the Sys.Net.WebRequest javascript method that you can find inhttp://ajax.asp.net/docs


paul.vencill:

If you're using the asp.net ajax framework (as posting on this forum would indicate), then by far your easiest method is to use the Sys.Net.WebRequest javascript method that you can find inhttp://ajax.asp.net/docs


paul.vencill:

If you're using the asp.net ajax framework (as posting on this forum would indicate), then by far your easiest method is to use the Sys.Net.WebRequest javascript method that you can find inhttp://ajax.asp.net/docs

i'm usingxmlhttprequest


Yeah, that's the object; I'm talking about the .js library / framework... Sys.Net.WebRequest fires an XmlHttpRequest under the hood, it just abstracts the interface for you to make it easier (like most ajax frameworks do)...


paul.vencill:

Yeah, that's the object; I'm talking about the .js library / framework... Sys.Net.WebRequest fires an XmlHttpRequest under the hood, it just abstracts the interface for you to make it easier (like most ajax frameworks do)...

i dont know if we are on same page

my questions is pretty simple..

i just need an example: how to insert data into db usingxmlhttprequest.

thanks.


Hello,

I'm from Earth too..

Really, good to see you here.

I think that you don't add data with result from server at the client side (web browser).

But you have(might, may be not) to utilize the data posted with xmlhttprequest at the SERVER.

This is the way of EARTH People doing, just joke!!!


Unless you're talking about something I'm not familiar with, XmlHttpRequest is an object that is exposed by modern browsers which allows you to communicate with the server without doing a full page postback. The AsP.Net ajax extensions Javascript object called Sys.Net.WebRequest is a wrapper around the XmlHttpRequest object which allows you to access it without necessarily knowing all the gory details.

As the other poster said, you don't insert data into a database using XmlHttpRequest, typically, what you do is make a request to your web server using XmlHttpRequest, and then the web server resource that you called w/ the XmlHttpRequest object parses that request and does 'something' with it, potentially inserting a record in the database. There's loads of examples of this under the docs of this site. http://ajax.asp.net/docs

No comments:

Post a Comment