Ajax Talk - Asynchronous javascript and xml discussion board
 FAQ   Search    Usergroups      Register   Profile   Check your messages   Log in 
Signup now to enjoy a range of free membership advantages !!
Ajax Talk - Moderators Wanted
AJAX is not comunicating with server script

 
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help
View previous topic :: View next topic  
Author Message
kent-ru
New one
New one


Joined: 04 Dec 2008
Posts: 1

PostPosted: Thu Dec 04, 2008 1:33 am    Post subject: AJAX is not comunicating with server script Reply with quote

Hello! Got a nice forum going here! Browsed it lots in need of solutions. But this problem i cant find answers to wherever!

The problem is that AJAX isn't communicating with the server script, and therefore I cant update my SQL tables. I've been over the scripts a hundred times, and I've probably blocked up some nerves in my head. So I ask you to please look over the code for me. There's of course a problem there, but I don't see it.

Let's start with the form (fb_edit_user.asp), this file is included, so that's why there's no body,head etc tags:
Code:

<!-- #INCLUDE file = "../../site_login/login_verify.asp" -->
<!-- #INCLUDE file = "sys/SQL_open.asp" -->

<%
response.expires=-1
ID = Request.QueryString("ID")
%>

<%
sql_str = "SELECT user_id, user_name, user_lname, user_init, user_uname, user_pass, user_admin FROM tadmin_users_tbl WHERE user_id = '" & ID & "'"
Set RS = Conn.Execute (sql_str)
%>


<div class="facebox_head">Rediger bruker</div><br>

<table class="facebox_text">
   <tr>
      <td>Endre ønskede felter, trykk deretter <font color="green">grønn</font> knapp for å lagre endringene. Trykk på <font color="red">rød</font> knapp for å avbryte og ikke lagre endringer.</td>
   </tr>
</table>

<div>&nbsp;</div>
<form id="edit_user_form" class="edit_user_form" name="edit_user_form" method="post">

<table id ="edit_user_form_tbl" width="350px">
   <tr>
      <td class="facebox_text">&nbsp;</td>
      <td><input id="form_id" name="form_id" type="hidden" value="<%=RS("user_id")%>" />
</td>
   </tr>

   <tr>
      <td class="facebox_text">Fornavn:</td>
      <td><input id="form_name" class="form_input" name="form_name" type="text" value="<%=RS("user_name")%>" />
      <div id="error_form_name_short" class="facebox_error">Fornavnet er for kort</div>
      <div id="error_form_name_none" class="facebox_error">Skriv inn fornavnet</div></td>
   </tr>
   <tr>
      <td class="facebox_text">&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
   <tr>
      <td class="facebox_text">Etternavn:</td>
      <td><input id="form_lname" class="form_input" name="form_lname" type="text" value="<%=RS("user_lname")%>"/>
      <div id="error_form_lname_short" class="facebox_error">Etternavnet er for kort</div>
      <div id="error_form_lname_none" class="facebox_error">Skriv inn etternavnet</div></td>
   </tr>
   <tr>
      <td class="facebox_text">&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
   <tr>
      <td class="facebox_text">Brukernavn:</td>
      <td><input id="form_uname" class="form_input" name="form_uname" type="text" value="<%=RS("user_uname")%>"/>
      <div id="error_form_uname_short" class="facebox_error">Brukernavnet er for kort</div>
      <div id="error_form_uname_none" class="facebox_error">Skriv inn brukernavnet</div>
      <div id="error_form_uname_exist" class="facebox_error">En annen bruker har samme brukernavn, du må lage et annet</div></td>
   </tr>
   <tr>
      <td class="facebox_text">&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
   <tr>
      <td class="facebox_text">Initialer:</td>
      <td><input id="form_init" class="form_input" name="form_init" type="text" value="<%=RS("user_init")%>"/>
      <div id="error_form_init_short" class="facebox_error">For få initialer</div>
      <div id="error_form_init_long" class="facebox_error">For mange initialer, maks tre</div>
      <div id="error_form_init_none" class="facebox_error">Skriv inn initialene til brukeren</div>
      <div id="error_form_init_exist" class="facebox_error">En annen bruker har samme initialer, velg noen andre</div></td>
   </tr>
   <tr>
      <td class="facebox_text">&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
   <tr>
      <td class="facebox_text">Passord:</td>
      <td><input id="form_pass1" class="form_input" name="form_pass1" type="password" value="<%=RS("user_pass")%>"/>
      <div id="error_form_pass_short" class="facebox_error">Passordet er for kort, minst seks bokstaver og eller tall</div>
      <div id="error_form_pass_none" class="facebox_error">Skriv inn passordet</div>
      <div id="error_form_pass_uname" class="facebox_error">Passordet kan IKKE være likt brukernavnet</div>
</td>
   </tr>
   <tr>
      <td class="facebox_text">&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
   <tr>
      <td class="facebox_text">Gjenta passord:</td>
      <td><input id="form_pass2" class="form_input" name="form_pass2" type="password" value="<%=RS("user_pass")%>"/>
      <div id="error_form_pass_diff" class="facebox_error">Passordene er ikke like, prøv igjen.</div></td>
   </tr>

   <tr>
      <td id="facebox_text">&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
   <tr>
      <td class="facebox_text">Administrator:</td>
      <td><select name="form_admin" class="form_input">
            <option <%IF admin = "Ja" THEN%>selected="selected"<%END IF%>>Ja</option>
            <option <%IF admin = "Nei" THEN%>selected="selected"<%END IF%>>Nei</option>
         </select></td>
   </tr>
   <tr>
      <td class="facebox_text">&nbsp;</td>
      <td>&nbsp;</td>
   </tr>
</table>

<div align="right">
   <a href="javascript:EditUser()"><img id="green_button" class="facebox_button" alt="Ja" src="site_content/admin_users/img/accept.gif" width="20" height="20"></a>
   <a href="javascript:CloseFacebox()"><img class="facebox_button" alt="Nei" src="site_content/admin_users/img/delete.gif" width="20" height="20"></a></div>
</form>
<%Set RS = NOTHING%><!-- #INCLUDE file = "sys/SQL_close.asp" -->


And on to the JS and jquery/AJAX script (edit_user.js):
Code:

function EditUser() {

//$("#menu_login_button").click(function() {
         var form_name = $("#form_name").val();
         var form_lname = $("#form_lname").val();
         var form_init = $("#form_init").val();
         var form_uname = $("#form_uname").val();
         var form_pass1 = $("#form_pass1").val();
         var form_pass2 = $("#form_pass2").val();
         var form_admin = $("#form_admin").val();
         
         var form_name_lenght = form_name.length;
         var form_lname_lenght = form_lname.length;
         var form_init_lenght = form_init.length;
         var form_uname_lenght = form_uname.length;
         var form_pass1_lenght = form_pass1.length;

       if(form_name=="")
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_name_none").slideDown("slow");
         }
      
      else if(form_name_lenght< 3)
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_name_short").slideDown("slow");
         }
         
      else if(form_lname=="")
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_lname_none").slideDown("slow");
         }
      
      else if(form_lname_lenght< 3)
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_lname_short").slideDown("slow");
         }
         
      else if(form_init=="")
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_init_none").slideDown("slow");
         }
      
      else if(form_init_lenght< 2)
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_init_short").slideDown("slow");
         }
         
      else if(form_init_lenght> 3)
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_init_long").slideDown("slow");
         }
      
      else if(form_uname=="")
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_uname_none").slideDown("slow");
         }
      
      else if(form_uname_lenght< 6)
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_uname_short").slideDown("slow");
         }
         
      else if(form_pass1=="")
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_pass_none").slideDown("slow");
         }
      
      else if(form_pass1_lenght< 6)
         {
         $(".facebox_error").slideUp("slow");
         $("#error_form_pass_short").slideDown("slow");
         }
      else if(form_pass1==form_uname)
         {
         $(".facebox_error").slideUp("slow")
         $("#error_form_pass_uname").slideDown("slow");
         }
      else if(form_pass1!=form_pass2)
         {
         $(".facebox_error").slideUp("slow")
         $("#error_form_pass_diff").slideDown("slow");
         }
      else
         {
         $(".facebox_error").slideUp("slow")
         
            var edit_user_form = "#edit_user_form";
            var xmlStream_edit = $(edit_user_form).serialize();
            
            var ajaxResponse_edit;
                  $.ajax({type: "POST",
                  url: "site_content/admin_users/fb_edit_user_action.asp",
                  data: xmlStream_edit,
                  success: function(ajaxResponse_edit){
                  alert (xmlStream_edit);
                     if(ajaxResponse_edit=="OK"){
                        $(".error_msg").slideUp("slow")
                        $("#edit_user_form_tbl").slideUp(500);
                        $("#green_button").fadeOut(500);
                        $("#edit_user_success").fadeIn(500);
                        alert(ajaxResponse_edit +" OK");
                        }
                     else if(ajaxResponse_edit=="ERROR"){
                        $("#add_user_error").slideDown("slow");
                        alert(ajaxResponse_edit +" ERROR");
                        }
                     else
                     {
                     alert(ajaxResponse_edit +" 01");
                     }
                  },
                  
                  error: function(ajaxResponse_edit){
                  alert (xmlStream_edit);
                        alert(ajaxResponse_edit +" 02");
                     ;}
            });
         }

        };


And finally the server side (fb_edit_user_action.asp):
Code:

<!-- #INCLUDE file = "../../site_login/login_verify.asp" -->
<!-- #INCLUDE file = "sys/SQL_open.asp" -->
<%
response.expires=-1

form_id = Request.Form("form_id")
form_name = Request.Form("form_name")
form_lname = Request.Form("form_lname")
form_init = Request.Form("form_init")
form_uname = Request.Form("form_uname")
form_pass = Request.Form("form_pass1")
form_admin = Request.Form("form_admin")

'validation
IF form_id="" OR form_name = "" OR form_lname = "" OR form_init = "" OR form_uname = "" OR form_pass = "" OR form_admin = "" THEN
Response.Write("ERROR")
ELSE

   sql_str =   "UPDATE tadmin_users_tbl " & _
                 " SET user_name = " & (form_name & ",") & _
                " user_lname = " &  (form_lname & ",") & _
                " user_init = " & (form_init & ",") & _
                " user_uname = " & (form_uname & ",") & _
                " user_pass = " & (form_pass & ",") & _
                " user_admin = " & (form_admin) & _
                " WHERE user_id = '" & form_id & "'"
         Set RS = Conn.Execute (sql_str)
         Set RS = NOTHING
         IF err.description = "" then
         Response.Write("OK")
         ELSE
      response.write(err.description)
      END IF

END IF
%><!-- #INCLUDE file = "sys/SQL_close.asp" -->

Thanks for any help!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ajaxtalk.com Forum Index -> AJAX Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 Advertisements
 XML & Copyright Notice 
    


Powered by phpBB © 2001, 2005 phpBB Group

What is according to Wikipedia: Ajax Web2.0 XML E4X


Link to our site:

  


del.icio.us digg spurl wists simpy newsvine blinklist furl blogmarks yahoo! myweb smarking ma.gnolia segnalo reddit fark technorati cosmos


Normal Bookmark


Partner Button Links:
Codecrunch.com: Webmaster Tutorials    One Ajax


Partner Text Links:
quomon | web20log | ajaxmatters | tableless | 456bereastreet | music charts | gift ideas | competitions | free xbox 360 | link trade ?


Credits:
it consultancy & project management lead generation zoekmachine optimalisatie steal these buttons seo expert