Jump to content

Jquery return


FooKelvin

Recommended Posts

Hi i have stuck with the ajax return success. Firstly let me explain what i going to do. i have a input form, the form have 3 field text. 1) start Date 2) end Date 3) quarter

the "quarter" field is a drop down list. i have a database to store the date of period of Q1,Q2,Q3,Q4. so i want to have, when a user select a drop down, the date will return the Q1 Period.

For now, i'am able to return the result like this: [{"qstartDate":"11/1/2014","qendDate":"1/31/2014"}]

But, when i wanted to return the date into my form, it fail. So, Here is my Code

$("#slc-quarter").change(function () {
    var quarter = $(this).val();
    $.ajax({
        url: "searchQuarterDetails.asp?term=" + quarter,
        success: function (data) {
                var a = qstartDate;
                alert(a)
            }
        //$("#qstartDate").val(ui.item.qstartDate);
        //$("#qendDate").val(ui.item.qendDate);
    })
})

The result that i get from this code after i change the drop down menu is: [object htmlinputelement]

Link to comment
Share on other sites

Hi requinix,

 

i have two pages. 

select.asp and source.asp

 

select.asp contain of 3 field. on of the field is drop down list. so, when user select the drop down, it trigger ajax "url: "source.asp?term=" + quarter".

so the page of source.asp?term="+quarter" display:

 

[{qstartDate: "2/1/2015", qendDate: "4/30/2015", label: "Q2"}

    0{qstartDate: "2/1/2015", qendDate: "4/30/2015", label: "Q2"}

        label"Q2"

       qendDate"4/30/2015"

       qstartDate"2/1/2015"

 

I need to take the "qendDate" value and "qstartDate" value.

Edited by FooKelvin
Link to comment
Share on other sites

So something like this then?

$("#slc-quarter").change(function () {
var quarter = $(this).val();
$.ajax({
url: "searchQuarterDetails.asp?term=" + quarter,
success: function (data) {
$("#qstartDate").val(data[0].qstartDate);
$("#qendDate").val(data[0].qendDate);
}
})
})
Link to comment
Share on other sites

Try:

$("#slc-quarter").change(function () {
var quarter = $(this).val();
$.ajax({
url: "searchQuarterDetails.asp?term=" + quarter,
dataType: 'json',
success: function (data) {
$("#qstartDate").val(data[0].qstartDate);
$("#qendDate").val(data[0].qendDate);
}
})
})
  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.