473,406 Members | 2,451 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Ajax Request problem

42
Hello people.

I have a website portal where I am trying to delete an object, by pressing a button. It does not work and I am getting an error. The HTML part of the request is following:

[HTML]<a href="javascript:makeRequest('set/post.php?actueel&del&[[ID]]');" onclick="return confirm('Weet u zeker dat u dit item wilt verwijderen?')" onmouseover="dragable = false" onmouseout="dragable = true"><img src="[[url]]images/delete.jpg" height="20" width="20" border="0" alt="Verwijderen / Delete" align="absmiddle"/>[/HTML]


Where ID will be replaced by the record identifier.


makeRequest on Javascript looks like following:
Expand|Select|Wrap|Line Numbers
  1. function makeRequest(url,object) {
  2.     xhr = new XHR(url,object);
  3.  
  4.     }
  5. //Constructor
  6. function XHR(url,object) {
  7.     var http_request = null;
  8.     this._load(url,object);
  9. }
  10.  
  11. XHR.prototype._load = function(url,object) {
  12.     /*var _this = this;
  13.     this.http_request.onreadystatechange = function(){_this.getRequest()};
  14.     this.http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); 
  15.     this.http_request.send('xml=<root>' + ((object!=false)?get(document.getElementById(object)):'') +  '</root>');*/
  16.  
  17.     if (document.getElementById('textarea_url')){ 
  18.         document.getElementById('textarea_url').value += url + "\n\n" + ((object!=false)?get(document.getElementById(object)):'');
  19.     }
  20.  
  21.     var xml = ((object!=false)?get(document.getElementById(object)):'');
  22.  
  23.     $.ajax({
  24.         type: "POST",
  25.         url: url,
  26.         data: 'xml=<root>' + xml +  '</root>',
  27.         async: false,
  28.         complete: function(msg){
  29.             if (document.getElementById('textarea_code')) document.getElementById('textarea_code').value = msg;
  30.             try {
  31.                 //alert();
  32.                 var output = msg.responseXML.documentElement;
  33.                 process(output);
  34.             } catch(e) {
  35.                 //alert('niet goed');
  36.             }
  37.         }
  38.     });    
  39. }
The error message in Birebug is following:

$.ajax is not a function
_load("set/post.php?actueel&del&17", undefined) javascript.js (line 61)
XHR("set/post.php?actueel&del&17", undefined) javascript.js (line 41)
makeRequest("set/post.php?actueel&del&17", undefined) javascript.js (line 35)
[Break on this error] complete: function(msg){

Which makes me think that the 'object' parameter is undefined. This brings me to the real problem - the makeRequest works perfectly with other part in the code (when sending mail). So I cannot completely remove the parameter, but make some changes. This is the point where I don't how to change the code? Any help will be appreciated and more information will be provided.
Sep 16 '08 #1
2 2165
Dormilich
8,658 Expert Mod 8TB
although I have no experience with Prototype's syntax, it looks as if $.ajax is supposed to be an object (literal notation!) but I'm missing a = somewhere. You should have a look at the Prototype documentation (or something to make the syntax clear).

regards
Sep 16 '08 #2
rnd me
427 Expert 256MB
try combining the actions:


not:
a href="javascript:makeRequest('set/post.php?actueel&del&[[ID]]');" onclick="return confirm('Weet u zeker dat u dit item wilt verwijderen?')"


but:
a href="javascript: if(confirm('Weet u zeker dat u dit item wilt verwijderen?')) { makeRequest('set/post.php?actueel&del&[[ID]]'); }"
Sep 16 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great...
5
by: Martin | last post by:
Hello NG, I've been doing some AJAX for a few weeks now. The basics worked fine so far, but now I've got the following problem which I can't solve: With AJAX you typically update/replace only...
3
by: Simon | last post by:
I have the following code in Javascript which is creating and sending an XMLHttpRequest . <code> var xmlHttp; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlHttp = new...
13
by: Marvin Zhang | last post by:
Hi, I'm not familiar with web programming, but I have a problem here. I have a page. When a user click one button on it, I will use AJAX to request a PHP script which will do a bunch of tasks,...
17
by: Arjen | last post by:
Hi, I want to reload 2 divs at one click. Ive tried: <a href = "javascript:void(0);"...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
3
rizwan6feb
by: rizwan6feb | last post by:
Hi experts! Recently i was working on "Form Validation Using Ajax". My form validation was creating problem, when a user changes focus too quickly. I had a post related to this, but was unable to...
29
by: zalek | last post by:
I am writing application with Ajax in sync mode - xmlHttp.open("GET", url, false). I noticed that in FireFox handler doesn't starts. It starts when I use xmlHttp.open("GET", url,true). I need to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.