• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

ASPAJAX updating data from the database

Hello,

I want to do something similar that's posted in the following site...
http://classicaspreference.com/aspexamples/inlineajaxedit/default.asp

When I copy and paste the code, "EDIT" link does not work. When I click on it, nothing happened.

Anyone please help me, what do I need to change in the code in order "EDIT" link to work.

Thanks,
0
andrishelp
Asked:
andrishelp
  • 2
  • 2
  • 2
  • +1
2 Solutions
 
mgfranzCommented:
Did you get the code from http://classicaspreference.com/aspexamples/inlineajaxedit/codepage.html?  You know there is a database associated with this page too that needs to be downloaded..
0
 
DesignbyonyxCommented:
That script is using ActiveXObject - which only works in IE... so my first question would be, are you using IE?

Next, in the file 'ajax_example.asp', did you "change the referrer check on line 9" as instructed by the author?
0
 
mgfranzCommented:
The issue of ActiveX objects is not a problem.  Take a look at this code;

//Browser Support Code
function ajaxFunction(key){
var ajaxRequest; // The variable that makes Ajax possible!

try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser broke!");
return false;

The demo runs on all decent browsers.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
andrishelpAuthor Commented:
The browser is not an issue because I tried IE and FireFox but it still EDIT link not functioning at all.
I changed database to different database.
Next, in the file 'ajax_example.asp', all the referrer code I out it in comment.
Any other suggestions that I can try. PLEASE HELP! Thanks,
0
 
RobOwner (Aidellio)Commented:
I would start by making it easy for yourself and use either mootools or jQuery to handle the client side AJAX requests.  Both are well documented and make it easy for using AJAX
0
 
andrishelpAuthor Commented:
@tagit: I haven't used mootools before. If you can, would you provide me a some examples that I can start learning mootools and apply to my question? Thanks.
0
 
RobOwner (Aidellio)Commented:
sure you'll only need the "core" that you can download here:

http://mootools.net/download/get/mootools-core-1.3-full-compat-yc.js

then you need to reference it in the html header

<script type='text/javascript' src='mootools-core-1.3-full-compat-yc.js'></script>

your edit link would look something like this:

<a href="javascript:EditItem('item1')">Edit</a>

What data is send to your edit.asp script is totally up to you but it will define what 'data' is set to.  for this example i have used the id of the element you are editing as well as passing it's contents.  you might want to set this up differently such as having hidden fields within each element to make it easier to send data back and forth to the server
// a sample function called when clicking EDIT

function EditItem(element) {

    var myRequest = new Request.HTML({
	url: 'edit.asp',
	method: 'post',
	data: 'id='+element.id+'content='+element.innerHTML,
	update: $(id)
    });

    myRequest.send();
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now