Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7180235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:18:18+00:00 2026-05-28T17:18:18+00:00

I have a button edit in every article, once the author of this article

  • 0

I have a button “edit” in every article, once the author of this article is logged in..
when the author views his article, he can click the button to start editing.

After a “onclick” event … the ID of the article will be sent to javascript, and the editing Box will load using ajax, with another form inputs and button “save”.

The problem is that , My database encoding is “UTF-8″… that means that when the user adds a new article, the article will display correctly on the website.

But once the page of the form in which he must edit loads , and once he clicks save , he will get all his data lost and changed encoding.

this is the page button (the button “edit” which loads the box) AND the div in which will appear the editing box:

echo '
<div id="edit"></div> 
<input type="button" class="btn" id="edt'.$v[0].'" onclick="editme('.$v[0].');" 
value="Edit">';

where $v[0] is the ID of the article.

this is the javascript function that will load the box for this article:

function editme(id){         /*function editme with the Article id as parameter*/
var req=new getXHR();        /* creation of xmlhttprequest object*/
var altr=Math.random();      /* a random to avoid URL caching in some browsers*/
var url='http://mywebsite.com/edit.php?n='+id+'&altr='+altr;  /*the requesting URL*/
req.open('GET',url,true);      //open the requesting url using GET method syncronously
req.onreadystatechange=function(){
if (req.readyState==4){    /*readyState*/
if (req.status==200){      /*status ==200*/
   document.getElementById("edit").innerHTML=req.responseText;    /*return response as an html form for editing*/
}
}
else{
document.getElementById("edit").innerHTML="Loading..."; /***wait loading message*/
}
};
req.send(null);  /*paramerters sending is null, cuz we have GET method*/


}

keep in mind that req is my XMLhttpRequest or ActiveXObject Object according to the browser client has.

the ajax function loads this Request’s result into the div #edit :

 'http://mywebsite.com/edit.php?n='+id+'&altr='+altr;

The PHP page is edit.php, here’s its source code:

<?php
include 'global/config.php'; //configuration and initialization of the constants
include 'global/connection.inc.php'; // connection settings
include MODELS_DIR.'disp.php';   // here I wrote display functions
include MODELS_DIR.'update.php'; // here are all updating functions 
if (isset($_GET['edit']) && !empty($_GET['edit']) && isset($_GET['n']) 
&& !empty($_GET['n'])){   //test if there's the number of the article in the URL..etc
$update=new update();   // update object
$redirect=$update->updateArticle($_GET['n'],$_GET['pv']); //update article and return redirection string to redirect to a new page
echo '<script>window.location.href="'.$redirect.'";</script>'; //redirection
}
$objet=new disp();     // display the whole fields of the article in form
$annonce=$objet->viewItem($pdo->quote($_GET['n']),'Articles_tbl','id_annonce','');//view article in a form (editing mode)


include VIEWS_DIR.'edit.php';  //the form of the editing in the views directory

once the ajax sends the number of the article to the edit.php controller, it loads the update functions (update.php) and display functions(disp.php) … and loads the form in the view … once editing is finished ..it redirects the user to the page of the edited article.

The problem is that all the files have the encoding “UTF-8” … but I still have problem with encoding french and arabic characters.

Thank you in advance .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:18:19+00:00Added an answer on May 28, 2026 at 5:18 pm

    I’m not sure but maybe problem is that your server sends data encoded iso-8859-1 instead of utf-8.
    Try to send a header("Content-Type: text/html; charset=UTF-8"); before you send data to javascript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, i have 2 edit controls and a button in my main window; in
I have a page where the user can edit various content using buttons and
I have one issue with UInavigationcontroller In my firstview i have button.If i click
I have a button on my home screen that will add an edit text
I have three button INSERT,EDIT and DELETE on sample.aspx page in .net application.I am
I have created a grouped table view & I had a edit button in
I have an Edit button in my navigation bar, and I have an table
I have a UITableView that has a disclosure button on every row. When the
I have created my own ControlTemplate for Button, like this: <Style x:Key=LightButtonStyle TargetType={x:Type ButtonBase}>
I have an edit button that when pressed puts the entire table into edit

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.