简体   繁体   中英

How to call aspx page from javascript with query string

Currently the functionality of a web app I am designing(I can not tell real details) is as follows :

alert('Hi');
var args = ShowModalDialogue(sURL,'','');
if(args[0] == 'Pass')
 alert('Bye');

Now I want to replace ShowModalDialogue with ModalPopupExtender. But the problem is I don't know how I can call aspx page using Javascript/Jquery and how to return values to calling javascript in the form of array?

Can anyone please help me out?

Thanks in advance.

You can use jquery to make an ajax call to your aspx.

var query = 'value1';

$.ajax({
            type: "POST",
            url: "my_asp_file.aspx?q="+query,
            async: true,
            dataType: "json",
            data: data,
            success: function(response) {

var js_object = JSON.parse(response);



            },

            error: function() {



            }

        });

Then you can use JSON.parse() to convert the returned JSON element to a JS Object. Remember to convert the output of your query in ASPX to a JSON object (in your ASPX file).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM