Jump to content

Php/ajax help


Markus_Newhart

Recommended Posts

I need some help. Im trying to call a php function in ajax. The data variable needs to be inside the called function.

Like: 

_("statusarea").innerHTML = '<div><?php showBBcodes('+data+'); ?></div>';
				

But no matter what i do it wont call it and if it does call it it wont show the data.

Link to comment
https://forums.phpfreaks.com/topic/285310-phpajax-help/
Share on other sites


function showBBcodes($text) {

// BBcode array
$find = array(
'~\[b\](.*?)\[/b\]~s',
'~\[i\](.*?)\[/i\]~s',
'~\[u\](.*?)\[/u\]~s',
'~\[quote\](.*?)\[/quote\]~s',
'~\[size=(.*?)\](.*?)\[/size\]~s',
'~\[color=(.*?)\](.*?)\[/color\]~s',
'~\[url\]((?:ftp|https?)://.*?)\[/url\]~s',
'~\[img\](https?://.*?\.(?:jpg|jpeg|gif|png|bmp))\[/img\]~s'
);

// HTML tags to replace BBcode
$replace = array(
'<b>$1</b>',
'<i>$1</i>',
'<span style="text-decoration:underline;">$1</span>',
'<pre>$1</'.'pre>',
'<span style="font-size:$1px;">$2</span>',
'<span style="color:$1;">$2</span>',
'<a href="$1">$1</a>',
'<img src="$1" alt="" />'
);

// Replacing the BBcodes with corresponding HTML tags
return preg_replace($find,$replace,$text);
}

Link to comment
https://forums.phpfreaks.com/topic/285310-phpajax-help/#findComment-1464985
Share on other sites

code in a browser cannot CALL a function on a server. the only thing that a browser can do is make a http request to the server, where the server-side code takes the submitted data (post, get, files, or cookie) and uses those values to perform some action.

 

i recommend you read up on what ajax stands for and read some ajax/php examples.

Link to comment
https://forums.phpfreaks.com/topic/285310-phpajax-help/#findComment-1465408
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.