如何在脚本标记中打印成功变量r。 r变量包含api中的值。但是我收到了php错误。
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
apply plugin: "de.mannodermaus.android-junit5"
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.appname"
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
// 2) Connect JUnit 5 to the runner
testInstrumentationRunnerArgument "runnerBuilder", "de.mannodermaus.junit5.AndroidJUnit5Builder"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility java_version
targetCompatibility java_version
}
packagingOptions {
exclude "META-INF/LICENSE*"
}
testOptions {
unitTests.all {
useJUnitPlatform()
}
}
buildToolsVersion = '28.0.3'
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0-beta01'
implementation 'androidx.core:core-ktx:1.2.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.2.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.13-beta-3'
implementation "com.google.dagger:dagger:$dagger_version"
kapt "com.google.dagger:dagger-compiler:${dagger_version}"
implementation "com.google.firebase:firebase-dynamic-links:${firebase_version}"
implementation "com.squareup.retrofit2:retrofit:${retrofit_version}"
implementation "com.github.bumptech.glide:glide:${glide_version}"
kapt "com.github.bumptech.glide:compiler:${glide_version}"
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.4.2")
}
我如何打印r.follow?
我尝试了不同的方法,但是没有用。请帮助我。
答案 0 :(得分:2)
您不需要将r.follow
与任何东西连接在一起,因此,请摆脱"'+r.follow+'"
。
您的contentType: 'json/application'
有两种错误:第一,正确的名称为application/json
;第二,正确的名称为POST
。其次,您要发送空数据,这不是有效的JSON。您正在发送URL中的所有参数,目前尚不清楚为什么要使用dataType:
。
如果要指定响应为JSON,则使用contentType:
选项而不是echo "
$('.btn1').click(function(){
$.ajax({
type: 'POST',
url: 'api/follow?id={$userid}&artid={$id}',
processData: false,
dataType: 'json',
data: '',
success: function(r){
console.log(r)
$('#followdiv').html(r.follow)
},
error: function(r){
}
});
});
";
完成。
// Add this module to your package.json & do npm install
const morgan = require('morgan');
// Will log calls on the express side
app.use(morgan('dev'));
// No need to do this every call, do it once
app.use(bodyParser.urlencoded({extended: false}));
// Handles the DELETE route specifically
app.delete('/configuration/config', api.token, (req, res, next) => {
console.log("/configuration/config called without problems");
// TODO: BODY of function
});