Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ajax/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
ajax调用JavaScript中的正确URL_Javascript_Ajax_Http_Url - Fatal编程技术网

ajax调用JavaScript中的正确URL

ajax调用JavaScript中的正确URL,javascript,ajax,http,url,Javascript,Ajax,Http,Url,我有一个GET ajax调用,如下所示: var changeUrl = "changePriority?newValue=" + targetValue + "&justification=" + justification if (dataInfo == "row") { changeUrl += "&id=" + id } changeUrl += "&executedConfigId=" + executedConfigId + "&currUse

我有一个GET ajax调用,如下所示:

var changeUrl = "changePriority?newValue=" + targetValue + "&justification=" + justification
if (dataInfo == "row") {
    changeUrl += "&id=" + id
}
changeUrl += "&executedConfigId=" + executedConfigId + "&currUser=" + currentUser + "&productName=" + productName + "&eventName=" + eventName + "&alertDetails=" + JSON.stringify(alertArray);
//if the selected signal is not null then we show the product names

$.ajax({
    url: changeUrl,
    type: "GET",
    success: function (data) {
        for (var index = 0; index < checkedRowList.length; index++) {
            var row = checkedRowList[index]
            signal.list_utils.change_priority(row, targetValue);
        }
        $('#change-priority-modal').modal('hide');
        if (applicationName == "Signal Management") {
            signal.list_utils.set_value(parent_row, 'dueIn', id, signal.list_utils.get_due_in, applicationName);
            $(parentField).html(targetValue);
        }
        location.reload();
    },
    error: function (exception) {
        console.log(exception);
    }
});
var changeUrl=“changePriority?newValue=“+targetValue+”&justify=“+justify
如果(数据信息=“行”){
changeUrl+=“&id=”+id
}
changeUrl+=“&ExecuteConfigId=“+ExecuteConfigId+”&currUser=“+currentUser+”&productName=“+productName+”&eventName=“+eventName+”&alertDetails=“+JSON.stringify(alertArray));
//如果所选信号不为空,则显示产品名称
$.ajax({
url:changeUrl,
键入:“获取”,
成功:功能(数据){
对于(var index=0;index
我在浏览器的开发者控制台中得到的
changeUrl
的值是:

http://localhost:8080/signal/singleCaseAlert/changePriority?newValue=Medium&justification=test%20justification%20first.&id=6816&executedConfigId=6704&currUser=15&productName=Wonder%20Product&eventName=1.Pyrexia&alertDetails=[{%22alertId%22:%226816%22,%22event%22:%221.发热%22,%22currentUser%22:%2215%22}]

但是我得到了一个400错误的请求状态和后端的http头解析错误。有人能帮我解决这个问题吗?

在你的JSON.stringify(alertArray)上,你还需要encodeURI()


更好的解决方案是在POST请求的正文中发送JSON,如果这在您的设计中是可行的

put
在第1行末尾以及第3行中,通过检查错误日志,找出您得到400的原因。@YashParekh使用分号没有帮助。@CBroe我已尝试解析url,它正确提供了所有查询字符串参数。
encodeURI(JSON.stringify(alertArray));