相关疑难解决方法(0)

jQuery $ .ajax()执行了两次?

这是一个按钮:

<input type="button" value="add to cart" id="addToCart" />
Run Code Online (Sandbox Code Playgroud)

和绑定事件:

$("#addToCart").bind('click',function(){
                $.ajax({
                    url: '/cartManager/add',
                    data:{
                        pictureId: currentImageId,
                        printSize: $("#size option:selected").val(),
                        paperType: $("#paperType option:selected").val(),
                        quantity: 1
                    },
                    success: function(){
                        $("#modal").html("<h1>??</h1><p>Closing in a sec</p>").delay(1000);
                        $("#modal").overlay().close();

                    }
                });
            return false;
            });
Run Code Online (Sandbox Code Playgroud)

一切工作都找不到一件令人烦恼的事情,我在Chrome开发者控制台中看到了两个请求:

  1. add/cartManager:
Request URL:http://127.0.0.1:8000/cartManager/add?pictureId=4&printSize=2&paperType=1&quantity=1
Request Method:GET
Status Code:301 MOVED PERMANENTLY
Run Code Online (Sandbox Code Playgroud)
  1. add/cartManager/add?:
Request URL:http://127.0.0.1:8000/cartManager/add/?pictureId=4&printSize=2&paperType=1&quantity=1
Request Method:GET
Status Code:201 CREATED
Run Code Online (Sandbox Code Playgroud)

两者的请求标头几乎相同,是请求标头中的唯一区别:

首先是cartManager/add?pictureId =等等,第二个是cartManager/add /?pictureId - '/'之后/ add

我的javascript有问题吗?

javascript ajax jquery

6
推荐指数
1
解决办法
1万
查看次数

Phonegap jQuery ajax请求不起作用

我想开发一个Phonegap应用程序,我正在使用jQuery Mobile.我正在通过PC上的Firefox进行开发和测试,因此这里描述的问题与Phonegap没有任何关系 - 这是一个Firefox PC问题:

以下代码不起作用,我需要一些帮助指出我正确的方向:

var loadWeather = function()
{
    // Request absetzen
    $.ajax(
    {
        // the URL for the request
        url : 'http://www.google.com/ig/api',

        // the data to send (will be converted to a query string)
        data : {
            weather : 'Vienna'
        },

        // whether this is a POST or GET request
        type : 'GET',

        // the type of data we expect back
        dataType : 'xml',

        // code to run if the request succeeds; the response is passed to …
Run Code Online (Sandbox Code Playgroud)

jquery cordova

0
推荐指数
1
解决办法
1万
查看次数

标签 统计

jquery ×2

ajax ×1

cordova ×1

javascript ×1