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 8233411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:07:22+00:00 2026-06-07T18:07:22+00:00

I’ve got a page that needs POST data to get an ajax response. The

  • 0

I’ve got a page that needs POST data to get an ajax response. The information relying on the POST data displays fine. However, after that, if the user wants to update some of the displayed data, I want to make another ajax call to update it on the fly. Then comes the problem as the first script doesn’t get any POST data from the page that the user requests to update the information.

Right now I have this, which, obviously is giving me the problem

$(document).ready(function(){

            var uid = <?php echo $_POST['user_id']; ?>;
            $.ajax({
                type: "POST",
                data : {user_id:uid},
                cache: false,
                url:"modules/user/showuserdata.php",                    
                success : function (data) {
                    $("#response").html(data);
                }
            })


        });

        $('#commit-changes').click(function(){

            $('#commit-user').submit();
            $.ajax({
                type: "POST",
                data: $("#commit-user").serialize(),
                cache: false,
                url:"modules/user/updateuser.php",
                success : function(data){
                    $("#response-update").html(data);
                }

            })
        });

The javascript error that chrome outputs is

 $(document).ready(function(){

            var uid = <br />
Uncaught SyntaxError: Unexpected token <
<b>Notice</b>:  Undefined index: user_id in <b>C:\xampp\htdocs\inacesso\admin\edituser.php</b> on line <b>73</b><br />
;

I’ve ommited the html for a better reading, but if necessary please notice me.

Any hint on how I can bypass this? I didn’t want to use SESSION variables…

Glad for all the help I can have on this.

EDIT

HTML response of the showuserdata.php

$user = new Users();

 $id = $_POST['user_id'];


 $rcs_user = $user->getUserByID($id);


 $rcs_roles = $user->getRoles();
 $role ='';
 foreach($rcs_roles as $roles)
 {
    if($roles->role_number == $rcs_user->permissao) 
        $role .= '<option value="'.$roles->role_number.'" selected="selected">'.$roles->role.'</option>';
    else
        $role.= '<option value="'.$roles->role_number.'">'.$roles->role.'</option>';
 }

 if($rcs_user->activo == 0)
 {
     $activo = '<input type="checkbox" name="activo" class="on_off_checkbox"  value="1"   />';
 }
 else
 {
     $activo = '<input type="checkbox" name="activo" class="on_off_checkbox" checked="checked"  value="1"   />';
 }


 $response = '';

 $response.='<form id="validation commit-user" action="" method="post"> 
                                <fieldset >
                                <input type="hidden" name="user_id" value="'.$_POST['user_id'].'"/>
                                <legend>Actualizar Dados Utilizador</legend>
                                      <div class="section ">
                                      <label>Nome<small>Insira o seu nome</small></label>   
                                      <div> 
                                      <input type="text" class="validate[required,custom[onlyLetterSp]] large" name="nome" id="f_required" value="'.utf8_encode($rcs_user->nome).'">
                                      </div>                                      
                                      </div>';
 $response.='<div class="section ">
                                      <label> Email<small>Insira o seu email</small></label>   
                                      <div> 
                                      <input type="text" class="validate[required,custom[email]] large" name="email" id="e_required" value="'.  utf8_encode($rcs_user->email).'">
                                      </div>
                                      </div>';

 $response.= '<div class="section">
                                    <label>Permissões<small>Seleccione o tipo de utilizador </small></label>   
                                    <div>
                                        <select class="medium" name="role">

                                                   '.$role.'                                                 

                                        </select>       
                                  </div>
                                  </div>                                      
                                 <div class="section">
                                        <label>Activo<small>Activar utilizador</small></label>   
                                         <div>
                                            '.$activo.'
                                            <span class="f_help">ON / OFF  </span> 
                                        </div>
                                  </div>

                                  <div class="section last">
                                  <div>
                                      <a href="" id="commit-changes" class="uibutton submit_form" name="submit">Submeter</a><a class="uibutton special"   onClick="ResetForm()" title="Limpar Formulário"   >Limpar Formulário</a>
                                 </div>
                                 </div>

                                </fieldset></form>';



   echo $response;
  • 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-06-07T18:07:24+00:00Added an answer on June 7, 2026 at 6:07 pm

    The problem is that data is loaded through ajax calls.

    I’ve solved this issue using .live or .on events of jQuery.

    Thank you for your efforts!

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:

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.