Reputation: 1164
I am new in jquery and I having trouble in converting my JavaScript into jquery ajax I tried but I did not get it properly if anyone can help me I shall be very thankful to him/her.
how my code works:
When i click on a edit button a popup is displayed showing record of a person and we can edit it in popup and then save it.
This is how it looks like:
This is my JavaScript Ajax code:
function update(str)
{
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("dialog").innerHTML=xmlhttp.responseText;
$( "#dialog" ).dialog();
}
}
xmlhttp.open("GET","updateattendence.php?q="+str,true);
xmlhttp.send();
}
Here is my HTML code:
<div id="dialog" title="Edit">
<div id="txtHint"></div>
</div>
Problem: I have tried jquery get method but I can don't know how to call my JavaScript function. and It is showing nothing.
Upvotes: 3
Views: 1559
Reputation: 15490
function update(str)
{
if (str=="")
{
$("#txtHint").html("");
return;
}
$.ajax({
type : "GET",
url : "/updateattendence.php?q="+str,
success : function(responseText) {
$("#dialog").html(responseText);
$( "#dialog" ).dialog();
}
});
}
Upvotes: 2