Jquery Ajax call not working- help~
Help, I would need some idea to write in jquery style.
If there's any similar tutorial, it would be great.
-------------------
by using the normal js
onclick will call to js, submit page to perform task, then back to the same page.
<tr>
<td><a onclick='doChange(7)'><img src='active.gif'></a></td>
<td><a onclick='doChange(8)'><img src='active.gif'></a></td>
<td><a onclick='doTask(9)'><img src='active.gif'></a></td>
</tr>
function doChange(id)
{
form.submit ... bla bla bla
}
-----------------
Now with jquery and ajax onclick update to db and refresh this portion only.
By using jquery, I don't need to use onclick='doChange(7)' anymore.
I can use $("#7").click( function()....
event will tied to jquery.
How do I transform whole thing over? Create a unique id for every <a ?
Create a class grouping for <a ?
<tr>
<td><a><img id="" src='active.gif'></a></td>
<td><a><img id="" src='active.gif'></a></td>
<td><a><img id= "" src='active.gif'></a></td>
</tr>
?
How do I pass the dochange(7) id into jquery ajax data: ?
Blank of idea, how do totally convert it into jquery style?
$(document).ready(function() {
$("#a").click( function() {
alert('haha');
$.ajax({
url: "ajax_updater.asp",
type: "POST",
timeout: 5000,
beforeSend: function(){ },
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(XMLHttpRequest);
alert(textStatus);
alert(errorThrown);
},
success: function(output) {
var status= output
if(status==1){ alert('success') }
else{ alert('fail') }
},
complete: function(){ },
data: 'pk='+pk
});
alert('haha2');
});
})