1. Using native ajax :
2. Using JQuery ://Do the AJAX call
function processStateChange() {
if (window.XMLHttpRequest) {
// Non-IE browsers
req = new XMLHttpRequest();
req.onreadystatechange = processStateChange;
try {
req.open("GET", url, true);
} catch (e) {
alert("Server Communication Problem\n"+e);
}
req.send(null);
} else if (window.ActiveXObject) {
// IE
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange=processStateChange;
req.open("GET", url, true);
req.send();
}
}
if (req.readyState == 4) { // Complete
if (req.status == 200) { // OK response
//Split the text response into Span elements
spanElements =
splitTextIntoSpan(req.responseText);
//Use these span elements to update the page
replaceExistingWithNewHtml(spanElements);
} else {
alert("Problem with server response:\n "
+ req.statusText);
}
}
}
$.ajax({
type: "POST",
url: "some.php",
data: "name=John&location=Boston",
success: function(msg){
alert( "Data Saved: " + msg );
},
error : function() {}
});
3 Using Smart client : Use data source with Json Or XML
isc.DataSource.create({
ID:"contacts",
dataFormat:"json",
dataURL:employee.php",
fields:[
{name:"name"},
{name:"email"},
{name:"organization"},
{name:"phone"},
{name:"street", valueXPath:"address/street" },
{name:"city", valueXPath:"address/city" },
{name:"state", valueXPath:"address/state"},
{name:"zip", valueXPath:"address/zip" }
]
});
No comments:
Post a Comment
Thanks for your comment, will revert as soon as we read it.