I have an input field and I want that variable to be passed as part of the url paramter in a load request. So for example what I am trying is
var inputField= $j('#inputText').val开发者_开发百科();
$j(document).ready(function() {
$j(".button").click(function (){
$j('#result').load('http://site.com?parameter='+inputField'.aClass')
});
});
If I were trying to do this without the variable like
$j('#result').load('http://site.com?parameter=stuff .aClass')
it works fine
Can someone please show me the correct syntax to make this work?
You are missing a + in your code.
Try this(changed the code to include the $j('#inputText') in the ready event..just in case..
$j(document).ready(function() {
var inputField= $j('#inputText').val();
$j(".button").click(function (){
$j('#result').load('http://site.com?parameter='+inputField +' .aClass')
});
});
$j(document).ready(function() {
$j(".button").click(function (){
var inputField= $j('#inputText').val();
$j('#result').load('http://site.com?parameter='+inputField+' .aClass')
});
});
精彩评论