Reputation: 633
I want to display some information (in jquery dialog), so when user enters a value in the text box and on blur It should make an ajax call using that value and display information in the dialog box.
This is what i tried so far:
$(function () {
$('#MyTextbox').blur(function () {
var id = $(this).val();
if (id >= "1") {
alert(id);
ShowData();
}
});
});
function ShowData() {
$("#dialog").dialog();
}
Is there any other better way of doing this?
Upvotes: 0
Views: 489
Reputation: 23064
$(function () {
$("#dialog").dialog({ isOpen : false});//Create Dialog
$('#MyTextbox').blur(function () {
var id = parseInt($(this).val()); //See correction here
if(id >= 1) {
//Get content and append to dialog
$("#dialog").dialog("open");//Open dialog
}
});
});
Upvotes: 1
Reputation: 2255
If you have an ajax script in php yo can call it directly from the blur event function and pass html result to the dialog box.
$('#MyTextbox').blur(function () {
// the ajax call
$.get('ajaxScript.php',{id: $("this").val()},
function(data){
//the result in html to the dialog
$("#dialog").empty().append(data).dialog();
},'html');
});
hope this helps
Upvotes: 0