Ich möchte einige Informationen anzeigen (im Jquery-Dialogfeld). Wenn der Benutzer einen Wert in das Textfeld und für Unschärfe eingibt, sollte er mit diesem Wert einen Ajax-Aufruf durchführen und Informationen im Dialogfeld anzeigen.
Das habe ich bisher ausprobiert:
$(function () {
$("#MyTextbox").blur(function () {
var id = $(this).val();
if (id >= "1") {
alert(id);
ShowData();
}
});
});
function ShowData() {
$("#dialog").dialog();
}
Gibt es einen anderen besseren Weg, dies zu tun?
Antworten:
1 für die Antwort № 1$(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
}
});
});
0 für die Antwort № 2
Wenn Sie ein Ajax-Skript in PHP haben, können Sie es direkt von der Unschärfefunktion aufrufen und das HTML-Ergebnis an das Dialogfeld übergeben.
$("#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");
});
hoffe das hilft