我想要一个这样的网址,http://localhost/myproject/get-dishes/1 这是我的ajax请求代码
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LoginPageActivity">
<TextView
android:id="@+id/textView2"
android:layout_width="0dp"
android:layout_height="53dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Hi, Welcome to Safety xxxxxxx Please Login or Signup"
android:textAlignment="center"
android:textColor="@android:color/holo_green_dark"
android:textSize="20sp"
app:layout_constraintBottom_toTopOf="@+id/buttonLogin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.66"></TextView>
<Button
android:id="@+id/buttonLogin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.87" />
<EditText
android:id="@+id/editTextEmail"
android:layout_width="346dp"
android:layout_height="50dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:hint="email"
android:inputType="textEmailAddress"
app:layout_constraintBottom_toTopOf="@+id/editTextPassword"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/textView2"
app:layout_constraintVertical_bias="0.95" />
<EditText
android:id="@+id/editTextPassword"
android:layout_width="346dp"
android:layout_height="50dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:ems="10"
android:inputType="textPassword"
android:hint=" Password"
app:layout_constraintBottom_toTopOf="@+id/buttonLogin"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView2"
app:layout_constraintVertical_bias="0.87" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="219dp"
android:layout_height="229dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toTopOf="@+id/editTextEmail"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.503"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.233"
app:srcCompat="@drawable/safetyxxx" />
<TextView
android:id="@+id/textViewSignUp"
android:layout_width="345dp"
android:layout_height="35dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:text="Do Not Have An Account? Click Here"
android:textAlignment="center"
android:textColor="@android:color/holo_green_dark"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonLogin" />
<android.support.v4.widget.ContentLoadingProgressBar
android:id="@+id/progressbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="gone"/>
</android.support.constraint.ConstraintLayout>
答案 0 :(得分:0)
尝试另一种替代方式,如route()或to()函数。
答案 1 :(得分:0)
试试这个..
let url = "{{route('get',[':id-url'])}}";
url = url.replace(':id-url', $(this).val());
然后,将其解析为ajax
$.getJSON(url, function(data) {
var model = $('#dishDropDown');
model.empty();
$.each(data, function(index, element) {
model.append("<option value='"+element.id+"'>" + element.sub_cate_name + "</option>");
});
});