使用$ .getJSON以特定格式发送数据? [英] Using $.getJSON to send data in specific format?
本文介绍了使用$ .getJSON以特定格式发送数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$.getJSON('<?php echo $this->baseURL()?>/site/ajax/checkusername',
{username: $('#username').val()},
function(data)
{
if (data == "TRUE")
{
$("#available").text("This username is available!");
}
else
{
$("#available").text("This username is not available!");
}
}
);
返回以下请求网址:
http://my.local/site/ajax/checkusername?username=sdfsdf
我希望它以以下形式返回:
I would like it to return in the form:
http://my.local/site/ajax/checkusername/username/sdfsdf
如何实现?
推荐答案
$.getJSON('<?php echo $this->baseURL()?>/site/ajax/checkusername/username/' + encodeURIComponent($('#username').val()),
function(data)
{
if (data == "TRUE")
{
$("#available").text("This username is available!");
}
else
{
$("#available").text("This username is not available!");
}
}
);
这篇关于使用$ .getJSON以特定格式发送数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文