/    Sign up×
Community /Pin to ProfileBookmark

Help in AJAX Params…

Hi,

I use AJAX to get aspx content.
The ASP getting ‘div’ content to URL Line.
Like that:
……MyAsp?HTML=’ + document.GetElementbyID(‘DivHTML’).InnerHTML……..

and output is ‘getting’ HTML.

But it’s not getting this ‘InnerHTML’ to asp! and It’s not open my asp page!
I getting error page!

How to do it?

Please help!

to post a comment
JavaScript

14 Comments(s)

Copy linkTweet thisAlerts:
@Angry_Black_ManMay 05.2008 — the javascript commands are case sensitive. the proper way to access the div element is:

[COLOR="Red"]d[/COLOR]ocument.[COLOR="Red"]g[/COLOR]etElementById("DivHTML").[COLOR="Red"]i[/COLOR]nnerHTML

notice the lowercase characters in red.
Copy linkTweet thisAlerts:
@WizardNetauthorMay 05.2008 — but is not what I mean..

I want to send HTML content to asp page. and get it in ajax.

Well, I got to solution like that:

In HTML File (JS)

http.setRequestHeader("value", "<html><head><title>titles</title><head><body><b>hey</b></body></html>");

....

...


In asp:

Response.Write(Request.Headers("value"))

....


Well, It is send good for any values, but it's not send HTML tags..

have any Idea?
Copy linkTweet thisAlerts:
@A1ien51May 05.2008 — Why are you setting the value in the headers?

Eric
Copy linkTweet thisAlerts:
@WizardNetauthorMay 05.2008 — Because I dont want it to be in URL line.

Every body see it..

Also: I can't write that:

http://...../MyAsp.asp?value=<html><head>........
Copy linkTweet thisAlerts:
@A1ien51May 05.2008 — You should be using [B]post[/B] and not [B]get[/B]. Post does not add values to the url.

Eric
Copy linkTweet thisAlerts:
@WizardNetauthorMay 05.2008 — and how i get it in asp page? what command do it?
Copy linkTweet thisAlerts:
@WizardNetauthorMay 05.2008 — also, I what to send to asp HTML Code and get it back in alert message.

ASP:

response.write(Get_from_ajax("value"))


Like that
Copy linkTweet thisAlerts:
@A1ien51May 05.2008 — Basic ASP for reading the form: http://www.w3schools.com/asp/coll_form.asp

Eric
Copy linkTweet thisAlerts:
@A1ien51May 05.2008 — also, I what to send to asp HTML Code and get it back in alert message.

ASP:

response.write(Get_from_ajax("value"))


Like that[/QUOTE]



I really think that you need to find a tutorial on Ajax and learn from it. All of the stuff you are trying to do is rather basic.

Eric
Copy linkTweet thisAlerts:
@WizardNetauthorMay 05.2008 — but i tried this!


Look: I want to send HTML Content!

in normal text is working! but not in HTML Content, like Div tag!

JS:

var MyDiv = document.getElementById('divD').innerHTML;

http.open('POST', 'http://localhost/........./Handle.aspx',true);

http.onreadystatechange=function.......;

http.send("strCmd=" + myDiv); //This is work: http.send("strCmd=" + "d");

ASP:

Response.write("output: " & Request.Form("strCmd"))



MyDiv content: (Just AS IT'S SHOW ON ALERT FUNCTION):

<p>

<BLOCKQUOTE>h</BLOCKQUOTE>

<P></P>
Copy linkTweet thisAlerts:
@TeufelMay 05.2008 — You need to encodeURIComponent the value you're trying to send:

http.send(encodeURIComponent("userid=1234&password=4321"));
Copy linkTweet thisAlerts:
@WizardNetauthorMay 05.2008 — not working, but I think the problem is when I got the INNERHTML from the div, it's make me break line (new line) between this tags.

Like:

<b>

h</b>


So how I change all break line to in line?
Copy linkTweet thisAlerts:
@TeufelMay 05.2008 — innerHTML.replace(/s*/g, "")
Copy linkTweet thisAlerts:
@WizardNetauthorMay 05.2008 — Thank's!!! for all!!!
×

Success!

Help @WizardNet spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...