473,387 Members | 1,592 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,387 software developers and data experts.

Problem Debugging javascript/Ajax

2
I am trying to write a simple Ajax application using SUSE 10.2, Apache, PHP and Javascript.

I want to click on a table header and do some processing to update the table. i have a function mySort which is called when you click on a table header. It sets some fields on the page and calls a second function which does the xmlHttp.open and the xmlHttp.onreadystatechange calles. everything works fine the first time I click on a header. The fields are updated, the table is updated, there are no error messages in the Firefox error console or the Firebug window. However If I click on a header a second time I get an error message that mySort is not a function.

I have tried everything I can think of to fix this problem. I even went back to an old copy and reapplied all of the changes one by one until it stopped working to make sure that is where the problem was. I have also tried returning the onclick property from the PHP script.

In the PHP script I look up the new information for the table and rerturn the formatted table minus the tables tags. I then add the Table tags and the header line in the Javascript. everything works fine and keeps working it I take out the onclick property.

Below is the Javascript I am having problems with. I have examined the HTML before and after running the mySort function and I can find no differences.

Expand|Select|Wrap|Line Numbers
  1. myTable = '<table border=1><tr><th>Sel</th>';
  2. myTable = myTable + '<th\ onClick=\"mySort(\'pri\', 1 );\">pri</th>';
  3. myTable = myTable + '<th>Date</th><th>Rqstr</th><th>Status</th><th>Desc</th></tr>';
  4. myTable = myTable + statusRSP;
  5. myTable = myTable  + '</table>';
  6. document.getElementById("Layer2").innerHTML = myTable;
  7.  
layer2 holds the table and nothing else.

Thanks for any suggestions. If there is a better way to return the table from the PHP script please let me know.
May 7 '07 #1
4 1339
acoder
16,027 Expert Mod 8TB
You don't need to escape the double quotes within single quotes.
May 8 '07 #2
moho
21
just a tip: you can do xxx += zzzzz, saves some space
May 8 '07 #3
Smudly
2
Thanks for the replies. I removed the extra backslashs and tried again with the same results. Then I had the bright idea to rename the function. Once I renamed the function it started working. I am not sure what it was conflicting with but atleast it is working now.

Thanks again.
May 8 '07 #4
acoder
16,027 Expert Mod 8TB
Glad you got it working.
May 8 '07 #5

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

Similar topics

25
by: Jeff | last post by:
Use the MS Script Editor included free with MS Office 2002 and above, for debugging Internet Explorer (IE). This subject is of great interest to many JS developers, as there is no obvious, low...
1
by: Tom Kelly - Tampa | last post by:
For everyone who wants to watch Ajax in action using ASP.NET. I have come across a method to debug ajax script into server-side code, I am not sure if it will work with classic ASP, but it may...
8
by: Samik R. | last post by:
Hello, I am using the innerHTML property of a div placeholder to update the contents, and the HTML is provided from a perl script on the server side. The perl script gets called through AJAX when I...
2
by: shivendravikramsingh | last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
6
by: John Doe | last post by:
Here's my issue: I have an instant messenger type feature for my site, its basically an ajax IM feature. I run with a mysql backend on the site, i have a div on my main page that runs a javascript...
3
omerbutt
by: omerbutt | last post by:
hi there i have downloaded a prototype tooltip from http://www.nickstakenburg.com/projects/prototip/ the logic it uses is to call the script after creating the <div> for example i am using the...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
3
by: Phrank | last post by:
Hello I am teaching myself AJAX, and have now gotten to the point where syntax errors are removed. I am using Javascript and HTML for now, to get a dropdown menu. The failed script follows an...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.