AJAX - 多数据 [英] AJAX - multiple data

查看:129
本文介绍了AJAX - 多数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我坚持:我想提交使用AJAX的一种形式,但我不能找到一种方法,通过我的AJAX调用发送多个数据字段

I'm stuck: I'm trying to submit a form using AJAX, but I can't find a way to send multiple data fields via my AJAX call.

$(document).ready(function() {
  $("#btnSubmit").click(function()  {
    var status = $("#activitymessage").val();
    var name = "Ronny";
    $.ajax({
      type: "POST",
      url: "ajax/activity_save.php",
      **data: "status="+status+"name="+name"**,
      success: function(msg) {...

我已经试过各种东西:

I've tried all sorts of stuff:

data: {status: status, name: name},

甚至这样的东西只是为了测试目的:

Or even stuff like this just for testing purposes:

data: "status=testing&name=ronny",

但无论我尝试,我什么也没得到我的 activity_save.php 因而没有在我的SQL。

But whatever I try, I get nothing in my activity_save.php thus nothing in my SQL.

那么,什么是正确的语法,把更多的行数据在我的AJAX调用?

So, what's the correct syntax to put more lines of data in my AJAX call?

推荐答案

正确的语法是: HTTP://api.jquery .COM / jQuery.ajax /

data: {status: status, name: name},

如果不工作,我会提醒这些变量,以确保它们具有价值。

If that doesn't work I would alert those variables to make sure they have values.

这篇关于AJAX - 多数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆