Deepika
Deepika

Reputation: 331

How to use variable for url parameter in jquery ajax call?

$.ajax({
        type:"POST",
        url:"hostname/projfolder/webservice.php?callback=statusReturn&content="+str_table,
        contentType: "application/json; charset=utf-8",
        crossDomain:true,
        dataType:'jsonp',
        success:function statusReturn(data)
            {
            alert("in success");
            var parsedata=JSON.parse(JSON.stringify(data));
                var stats=parsedata["Status"];

            if("1"==stats)
            {   
                alert("success");
            }
            else
            {
                alert("failed");
            }
            }
        });

How can I display the contents of the "url" parameter in an alertbox to check what the parameter is containing?

It does not even enter in the "success" parameter. Please suggest me how can I do that.

Upvotes: 0

Views: 1584

Answers (3)

Akhil
Akhil

Reputation: 21

You can see your request parameter in firbug plugin of chrom or firefox

Upvotes: 0

N3m1s
N3m1s

Reputation: 139

You can put you url parameter in a variable like so:

var targetUrl = "hostname/projfolder/webservice.php?callback=statusReturn&content="+str_table";
//log your output
console.log(targetUrl, str_table);

Then use it in your ajax call:

$.ajax({
    type:"POST",
    url: targetUrl,
    ...

See this fiddle for full example

Upvotes: 1

Adeem
Adeem

Reputation: 1346

Try this.url if need to access within event of ajax call. All parameters of ajax call can be accessed via this object. So final statement will be

alter(this.url);

Upvotes: 0

Related Questions