Ajax - url参数与数据

时间:2016-07-27 05:53:39

标签: jquery ajax

在JQuery Ajax调用中,建议使用以下哪个?我知道两者相似但这两者之间有明显的优势吗?

使用URL Paramater进行Ajax调用。

public static void disableSMSReceiver(Context context){
ComponentName component = new ComponentName(context, YOUR_RECEIVER.class);
PackageManager pm = context.getPackageManager();
pm.setComponentEnabledSetting(
        component,
        PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
        PackageManager.DONT_KILL_APP);
}
使用参数

中的参数调用

或Ajax

$.ajax({
url: 'test.php?uAction=action&uType=type',
    dataType: 'json',
    success: function(data, status){
            $.each(data, function(i,item){
                });
            },
    error: function(){
            output.text('There was an error loading the data.');
        }
    });

1 个答案:

答案 0 :(得分:0)

如果您在ajax调用中创建url,请执行以下操作:

url: 'test.php?uAction=action&uType=type',

它的类型是get,你必须处理url编码机制以避免空格和其他字符。在第二种方法中,您不必担心URL编码键和值。

相关问题