I am just beginning to get the idea on how to put together the above four source codes to produce, in this case, a Contact Database/Display program.
On a 0-10 learning scale I feel like a 3.
My current problem is:

ContactRevise3.html calls revise.php with the following script:

<script type="text/javascript" >
	
		$.post("revise.php", {id: revId, revData: revFlg, dName: dispName}, showResultsFromServer, "json");
			 
	
//  ==================  showResults From Server  =====================	
	
			function showResultsFromServer(data) {	
		
				var content="<table border='3' cellpadding='5' bgcolor='#feede3' class='rTbl'>"
				+"<caption class='rTbl' ><big><b>Data currently stored in the database.</b></big></caption>\n"
				+"<caption></caption>"
				+ "<tbody><tr class='rTbl'><th class='rTbl'>Field</th><th class='rTbl'>Value</th></tr>\n";
				
				$.each(data, function(key, value) {
					
					if(key==="Name_ID") { return true; };
					content+= "<tr class='rTbl'><td class='rTbl'>" + key + "</td><td class='rTbl'>" + value + "</td></tr>\n"

				}); // $.each
		
				content+= "</tbody></table>";
				content+="<div class='controls'>";
				content+="<button type='button' name='revise' class='hov'"  
				+"onclick=\"window.location.href='ContactFrontEnd.php'\"> Go Back</button></div>\n"			
				$(content).appendTo("#rbox");
				
				$('#rbox').show();
				
				$("#rbox2").show();
				
			}; // showResults			 
</script>

The result is a page showing the header only. It is supposed to also show a table/form allowing
the revision of fields to be stored in the database. The array shown in form_output.png is returned from revise.php. When my current problem is solved that array will be returned to ContactRevise3.html as JSON
(json_encode($rowssaved) to be displayed by showResultsByServer() as above.

If I call revise.php by itself it works as intended. See form_output.png. If it is called as above all I get, looking at firebug output, is the generated source code. See generatedSource.png.

I am beginning to think, as there are no errors generated, that I have to append all this generated code to a <div> somehow.

If this is correct I'd like some advice on how to do it. Otherwise ???

Thanks in advance, RP.

My query didn't upload the .png files!

GUESS WHAT?? My fault.

whats rbox
probably you want $('#rbox').html(content);

Thanks for your quick reply.

Sorry I didn't explain the problem very well.

A typical session is.

1. Select a contact person from MYSql database.
2. Decide to change/add data in/to the record.
3. Call ContactRevise.html which in turn calls revise.php with $.post...
a. Revise.php generates a table/form showing all fields in that record
regardless of containing data or not.
b. Change or add data in the table/form and submit.
c. UPDATE the database and create an array of fields in the record that contain data only.
No blank fields.
d. Encode the array to JSON format.
e. RETURN the JSON data to ContactRevise.html to be displayed with
the callback function, showResultsFromServer(data).
4. ShowResultsFromServer(data) creates a table showing the UPDATED record data for the contact in <div id="#rbox">.

PROBLEM: In 3a. the table/form is NOT DISPLAYED. If I set up a test id to query the database
and run revise.php as a stand alone program the table/form displays fine and everything works.

revise.php WILL NOT WORK WHEN CAllED FROM ContactRevise.php.

What I've shown you is only what revise.php does now. It is intended to go as
far as displaying the array only.

Hope this adequately describes my problem now.

Thanks again, RP

there's nothing wrong with your code, have you tried alerting your content 1st? and where is your #rbox

and btw i don't think you are a scale of 3 out of 10, your code is complicated it uses, php + (jquery)ajax + json

Thanks vaultdweller, I'll upgrade myself to a 4.

I think that maybe the problem is this. The table/form I want to implement is really a mid-stage event. I am asking revise.php to produce this form. The user changes the data shown on the form, the data is updated by MySql, the database is again queried for the current data AND THEN the array is encoded and sent to the call back function in the preceding program. Revise.php is not showing the table/form to update. There is no problem with the array revise.php produces and subsequent code re: the call back. The question becomes WHY WON'T revise.php DISPLAY THE FORM TO CHANGE?

Don't forget, revise.php, on a standalone basis works very well.

(I'm giving myself a 2 on explaining myself.)

Here are the modules.

can you attach your database here as well? ill try to dump them on my database and try to work that here on my end

hey dude, i assume you know how to use firebug, try to check firebug's NET tab, and then check your request there, then click on the response tab, to see the response, because you could've error on your revise.php

ok try changing this

$.post("revise.php", {id: revId, revData: revFlg, dName: dispName}, showResultsFromServer, "json");

to

$.post("revise.php", {id: revId, revData: revFlg, dName: dispName}, showResultsFromServer);

ok ill be back ill just have my lunch

I can barely get around in Firebug. The generated source came from the results thing.

Here is the database I am using.

Don't forget I'm only interested in revise.php showing a table/form at this time. What Firebug shows is the generated code to produce the table/form.

firebug-response-body.txt is copied from Firebug.

That last array it shows is exactly what it should be before JSON encoding. All that above is supposed to generate the table/form inside revise.php so you can change the data on the fly. Looking at NET shows no errors.

Getting late here.Talk later.

hey dude, one thing is bugging me, if you use json to return values why are you commenting json_encode($rowsSaved)? and just so you know everything you echo or printf is returned when call ajax

btw i find it hard to debug here in my end because of your includes, i don't them files you know, well nevermind i don't know if im helping you but i don't really know what you want to achieve

Thanks vaultdweller,

I had to leave town for the day.

Tomorrow I will send you the files you need to run this properly. I actually thought about not giving you all the necessary files during my travels today. Sorry I wasted your time.

Regarding your comment re: echo or printf, you are saying, I think, that what I am trying to do is not possible. That is to call revise.php with an ajax call ==> $.post("#revise.php", {.....)<== and try to use printf to display a table/form. Do I read you correctly. This is exactly what I am trying to do.

Talk tomorrow.

Thanks for your help and time, RP

PS Yes you are helping me. Even a negative outcome is letting me progress.

Hi, Vaultdweller,

After thinking about this again and studying more questions/answers on forums and, before I went all out and sent you all the files for this application, I followed your advice and changed the $.post call with a slight variation. That and acting on your comment about PHP not being compatible with Jquery re: echo and printf WE seem to have solved my problem.

$.post("revise.php", {id: revId, revData: revFlg, dName: dispName}, showResultsFromServer, "json");

to:

$.post("revise.php", {id: revId, revData: revFlg, dName: dispName}, showResultsFromServer, "html");

Now it works the way I expected it to.

Thanks again for all your time and help.

RP

glad to help my friend, actually im just really giving you advise, it was really you who solved the problem :) , btw is this problem solved? one way of saying thanks is marking this thread solved :D

SOLVED:

Thanks Vaultdweller,

I put "Solved:" in the title of my last post. I thought I saw an icon somewhere that will put "Solved" in the proper place in the message but it must have been another forum.

RP

@pizzipie haha not like that my friend, i think there's a link there, just above the post textbox :D

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.