Put DB data into Visual Code block with AJAX |
Post Reply |
Author | |
snoopy
Newbie Joined: Jan 06 2017 Status: Offline Points: 27 |
Post Options
Thanks(0)
Posted: Jan 13 2017 at 6:05pm |
I have now a working page with a Visual Code block that fills itself with rows from a DB.
The Code Block uses PHP to do this, and it uses the command 'echo' to generate HTML code, to put the DB data into a table (displayed by the Visual Code block). Now I am struggling to use AJAX to do this instead and it almost works .... I have put the PHP code from the Visual Code block into a separate PHP file. The HTML code is received correctly from the PHP file by the 'xmlhttp.onreadystatechange = function()'. The problem is that I can't get the Visual Code block to output the HTML code as a table. When I use the code: var titleRows = this.responseText; $('.arrListBox').text(titleRows); the HTML code ('<TABLE .....') is displayed in the '.arrListBox' (the Visual Code block) instead of the DB data (the CD titles). I have also tested per the example at 'http://www.w3schools.com/php/php_ajax_database.asp' with '$('.arrListBox').innerHTML' and other combinations of params. without success. How do I get the Visual Code block to display the data resulting from the HTML code instead of the HTML code?? Best regards, Erland Edited by snoopy - Jan 13 2017 at 7:43pm |
|
I am running:
OE 1.56 R4 Windows 10 (64bit) v1607 UniServer Zero XIII 13.3.0 |
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(1)
|
Hi,
Instead of text() you should use html(), that's all |
|
snoopy
Newbie Joined: Jan 06 2017 Status: Offline Points: 27 |
Post Options
Thanks(0)
|
Thank's again Dmit!!
For future reference.... How do I find the name of the attribute I should use? Where to find the available attribute names? That is should I use: $('.arrListBox').text($titleRows); or... $('.arrListBox').val($titleRows); or... $('.arrListBox').html($titleRows); or... $('.arrListBox').attr('someOtherAttr', $titleRows); or some other name.... Best regards, Erland
|
|
I am running:
OE 1.56 R4 Windows 10 (64bit) v1607 UniServer Zero XIII 13.3.0 |
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(1)
|
Google and jQuery API help is your guide. Just type for example "jQuery val" in Google and you will see what it's for and examples of usage. There are many very good answers on StackOverflow as well, with ready-to-use examples
|
|
Dmit OE
Admin Group Joined: May 31 2012 Status: Offline Points: 5283 |
Post Options
Thanks(1)
|
P.S. An attribute in HTML is what's inside the declaration of a tag, example:
<div class='myclass' style='display:inline-block;" data-value='myvalue'> This DIV tag has 3 attributes: class, style and data-value |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |