/    Sign up×
Community /Pin to ProfileBookmark

Importing a table row with ajax

Hello,
How do I put a row in ajax in the middle of a table
It’s not ajax, <div id=”ajax-output”></div> how to place it in the middle of the table

“`
<script type=”text/javascript” language=”javascript”>
$(document).ready(function(){

$.ajax({
url: “ajax.php”,
type: “GET”,

cache: false,
success: function(dataResult){
$(“#ajax-output”).html(dataResult);

}
});
});
</script>
“`

index.php

“`
<table border=”1″ width=”32%”>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<div id=”ajax-output”></div>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
“`

ajax.php

“`
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
“`

Thank you from now

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumSep 18.2019 — jQuery's function replaceWith should enable you to replace the div#ajax-output by the new row:

https://api.jquery.com/replaceWith/
Copy linkTweet thisAlerts:
@gecekuleauthorSep 18.2019 — Thank you
Copy linkTweet thisAlerts:
@gecekuleauthorSep 22.2019 — I could not,

index.php

``<i>
</i>&lt;table cellpadding="4" cellspacing="0" border="0" align="center" width="90%" style="border-collapse:separate; border-bottom: none; border-top: none;" class="tborder" id="optionsform_table"&gt;

&lt;colgroup span="9"&gt;
&lt;col style="width:10%"&gt;&lt;/col&gt;
&lt;col style="width:20%"&gt;&lt;/col&gt;
&lt;col style="width:15%"&gt;&lt;/col&gt;
&lt;col style="width:10%"&gt;&lt;/col&gt;
&lt;col style="width:1%"&gt;&lt;/col&gt;
&lt;/colgroup&gt;

&lt;thead&gt;
&lt;tr&gt;
&lt;td class="tcat" align="center" colspan="4"&gt;&lt;b&gt;Üyeler Listesi&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;tr valign="top" align="center"&gt;
&lt;td class="thead" align="center"&gt;Adı Soyadı&lt;/td&gt;
&lt;td class="thead" align="center"&gt;Firma Adı&lt;/td&gt;
&lt;td class="thead" align="center"&gt;İl/İlçe/Semt&lt;/td&gt;
&lt;td class="thead" align="center"&gt;Firma E-Posta&lt;/td&gt;
&lt;td class="thead" align="center"&gt;Seç&lt;/td&gt;
&lt;/tr&gt;

&lt;tbody id="tbody_bbactive"&gt;

&lt;div id="ajax"&gt;&lt;/div&gt;

&lt;/tbody&gt;

&lt;thead&gt;
&lt;tr&gt;
&lt;td class="tcat" align="center" colspan="4"&gt;&lt;b&gt;Seçenekler&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;thead&gt;
&lt;tr&gt;
&lt;td class="tcat" align="center" colspan="4"&gt;&lt;b&gt;Gruplar&lt;/b&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/thead&gt;

&lt;/table&gt;<i>
</i>
`</CODE>

ajax.php

<br/>
<CODE>
`<i>
</i> &lt;?php
$css = 0;

while ($satir = $sonuc-&gt;fetch_assoc() ) {

$class = ($css % 2) ? "alt1" : "alt2";
?&gt;
&lt;tr valign="top"&gt;
&lt;td class="&lt;?php echo $class; ?&gt;"&gt;&lt;div class="smallfont"&gt;&lt;?php echo $satit['adi_soyadi']; ?&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td class="&lt;?php echo $class; ?&gt;"&gt;&lt;div class="smallfont"&gt;&lt;?php echo $satir['firma']; ?&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td class="&lt;?php echo $class; ?&gt;"&gt;&lt;div class="smallfont"&gt;&lt;?php echo $satir['il_ilce_semt']; ?&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td class="&lt;?php echo $class; ?&gt;"&gt;&lt;div class="smallfont"&gt;&lt;?php echo $satir['email']; ?&gt;&lt;/div&gt;&lt;/td&gt;
&lt;td class="&lt;?php echo $class; ?&gt;"&gt;&lt;div class="smallfont"&gt;&lt;input type="checkbox" class="emailsec" id="emailsec" value="&lt;?php echo $satir['email']; ?&gt;" /&gt;&lt;/div&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;?php
$css++;
}
$sonuc-&gt;free();
?&gt;<i>
</i>
`</CODE>

<C>
$('#ajax').replaceWith(dataResult);`

Can you help me
Copy linkTweet thisAlerts:
@gecekuleauthorSep 24.2019 — I solved the problem

He did not need $('#ajax').replaceWith(dataResult);

The problem was that the JavaScript code inside ajax.php

Thank you to everyone
×

Success!

Help @gecekule spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...