jQuery AJAX发送链接显示坏了

时间:2015-05-29 09:38:16

标签: php jquery ajax

var dlink="http://www.example.com/downloadPkpass.php?temp=f5d022b2-8596-45e7-811d-611d42a15b6c&serial=100000000000135";
jQuery.ajax({
                type:"POST",
                url:'../sendMail.php',
                data: "date="+date+"&vname="+vname+"&offer="+offer+"&expiry="+expiry+"&dlink="+dlink,
                success:function(res)
                {

                },
            })

我将这段代码用于我的jQuery Ajax代码。问题在于dlink变量。 但是在sendMail.php页面中我打印了$ _POST ,它显示在一个没有显示原始数据的破碎数组中。 在sendMail.php中它显示如下:

  

[dlink] =>   http://dompdf.github.io/   [serial] => 100000000000135

2 个答案:

答案 0 :(得分:2)

您需要正确编码您的值才能在网址中使用。最简单的方法是让jQuery通过传递一个对象来自动完成:

DECLARE @return_value int

EXEC    @return_value = [dbo].[Usp_makereservation]
        @refno = N'12',
        @propertyid = 2,
        @roomtype = N'R345',
        @groupcode = N'G25',
        @companycode = N'C422',
        @arrivaldate = N'1/2/3',
        @arrivalplan = N'fd',
        @departuredate = N'5/2/3',
        @departureplan = N'gdfgd',
        @createdby = 1,
        @subsrno = N'g',
        @roomno = N'fgd',
        @guesttitle = N'fdf',
        @lname = N'gdf',
        @fname = N'f',
        @mname = N'd',
        @address = N'dfg',
        @city = N'fdg',
        @state = N'fd',
        @country = 3,
        @zipcode = N'rt',
        @telno = N'etr',
        @mobile = N'et',
        @fax = N'r',
        @gueststatus = 4,
        @designation = N'ertre',
        @occupation = N'tert',
        @arrivalfrom = N'ret',
        @departureto = N'ret',
        @leader = 1,
        @spclinstrctn = N'er',
        @checkinflg = 1,
        @singlebooked = 2,
        @singleprovisional = 2,
        @singleconfirmed = 3,
        @singlewaitlisted = 2,
        @doublebooked = 23,
        @doubleprovisional = 2,
        @doubleconfirmed = 3,
        @doublewaitlisted = 23,
        @triplebooked = 23,
        @tripleprovisional = 23,
        @tripleconfirmed = 23,
        @triplewaitlisted = 23,
        @quadbooked = 2,
        @quadprovisional = 3,
        @quadconfirmed = 24,
        @quadwaitlisted = 23,
        @marketsegID = 432,
        @businesssrcID = 4,
        @guestcategoryID = 234,
        @gueststatusID = 234,
        @totalpax = 234,
        @adultpax = 23,
        @childpax = 4,
        @infantpax = 234,
        @extraadultpax = 23,
        @extrachildpax = 4234,
        @complementarypax = 23,
        @noshow = 4,
        @checkinrooms = 234,
        @checkinpax = 43232

SELECT  'Return Value' = @return_value

GO

如果您需要,也可以手动编码值(例如,当您不使用jQuery时):

data: {'date': date, 'vname': vname, 'offer': offer, 'expiry': expiry, 'dlink': dlink},

答案 1 :(得分:0)

声明数据的方法错误

 data: "date="+date+"&vname="+vname+"&offer="+offer+"&expiry="+expiry+"&dlink="+dlink,

数据的格式如下: -

data: {date: date, vname: vname,offer: offer, expiry: expiry, dlink: dlink},