jquery: show data after change event
i have this code:
<script>
$("#mod").change(function() {
var matches=str.match(/(EE|[EJU]).*(D)/i);
$.ajax({
type="post",
url="process.php",
data="matches",
cache=false,
开发者_C百科 async=false,
success= function(res){
$('#rslt').replaceWith("<div id='value'><h6>Tuner range is" + res + " .</h6></div>");
return this;
}
});
return false;
});
</script>
i want this code can show the result normally..where is my fault?
remove the return
s
and format as ( :
instead of =
)
$.ajax({
type:"post",
url:"process.php",
data:"matches=" + matches,
cache:false,
async:false,
success: function(res){
$('#rslt').replaceWith("<div id='value'><h6>Tuner range is" + res + " .</h6></div>");
// return this; <<--- remove that too...
}
})
and if you want matches
to be passed as data use data:"matches=" + matches,
...
and $_POST['matches']
is the way to get the value via PHP
<script>
$("#mod").change(function() {
var matches=str.match(/(EE|[EJU]).*(D)/i);
$.ajax({
type:"post",
url:"process.php",
data:"matches="+matches,
cache:false,
async:false,
success: function(res){
$('#rslt').replaceWith("<div id='value'><h6>Tuner range is" + res + " .</h6></div>");
}
});
});
</script>
精彩评论