1

I simply want to set up an ajaxurl in javascript to pass to my controller.

When trying to setup the url, it evaluates to 0 during the below attempts: Note that attrs.attachmentType & attrs.attachmentId have values associated with them.

var hoser = attrs.attachmentType & attrs.attachmentId;

                                ajaxUrl = root + 'FileUpload/upload?' & 'Type=' & attrs.attachmentType & 'ID=' & attrs.attachmentId;

If I just include the following, a proper value is seen inside the hoser variable.

var hoser = attrs.attachmentType;

What am I doing wrong where the url will not come out correctly?

1 Answer 1

2

You are using & symbols, not adding them to the string. By using these symbols, javascript is interpreting the right hand side of your statement to be a comparison and outputting the answer it thinks you want - in this case, a boolean representation of false: 0

Change your & symbols to strings. Like so:

 ajaxUrl = root + 'FileUpload/upload?' + '&' + 'Type=' + '&' + attrs.attachmentType + '&' + 'ID=' + '&' + attrs.attachmentId;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.