/    Sign up×
Community /Pin to ProfileBookmark

Passing HTML to PHP through AJAX – Linefeeds

Hello!

I’m trying to pass some html to a php script. Note, this is only on Windows platforms even though Mac has some problems to regarding adding extra tabs.
Anyway PC is my target.

I use escape(html) and send it through ajax. The problem I’m facing,
is that the data recieved does not convert linefeeds the correct way.

Here’s my php code:

switch ($this->language) {
case ‘SWE’:
$search = array(chr(229), chr(197), chr(228), chr(196), chr(246), chr(214), chr(187), chr(13));
$replace = array(‘å’, ‘Å’, ‘ä’, ‘Ä’, ‘ö’, ‘Ö’, ‘»’, ‘n’);
break;
}

$data = str_replace($search, $replace, $data);
return stripslashes($data);

NOTE:
The chr(13) should convert the linefeed to a ‘n’
I’ve also tried chr(10)….

Here’s the javascript:

this.xmlreq.send(‘&html=’ + escape(this.contentdocument.documentElement.innerHTML) + ‘&filename=&page_action=0’);

Hope someone can help me out!

Cheers
Adrian

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @amccool 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,
)...